S
S
Sland Show2016-08-26 22:03:37
Python
Sland Show, 2016-08-26 22:03:37

What is the difference between the concept of OOP in Python and in C-like languages?

Good day.
I'm familiar with python, but I'm still a beginner. To me, as a person who has been writing in C-like languages ​​(Java) for a long time, one thing is not very clear, which is related to the difference between classes and Objects.
In Python, there is a class and, accordingly, a separate entity as an object (or a virtual copy of the class).
But at the same time, when calling the method, it is imperative to pass self, since in Python the method is called precisely in the class, and already thanks to self, this method determines which instance of the class it works with.

class Test:
   def f(self):
          pass

Is it true that things are a little different in Java?
More specifically, I thought that objects in Java have their own methods within objects. And when a method is called, it is called from the object itself, and not from the class (where this class determines what exactly it should work with next)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Cheremisin, 2016-08-26
@SlandShow

No, it's the same in Java. only variables belong to an instance of a class, and methods are contained in the class itself, just the language notations are different.

M
Maxim Moseychuk, 2016-08-26
@fshp

How did you write in java for so long and did not learn about the this keyword?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question