-
-
Notifications
You must be signed in to change notification settings - Fork 27
Update python_oop.md #356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update python_oop.md #356
Conversation
"instance data and functions" together are called attributes, not methods. I believe methods are just the function part.
Thanks @jaeyungkim . This is indeed completely wrong and we appreciate the fix! |
@mmcky Could you please merge when ready and perhaps consider republishing? |
thanks @jstac and @jaeyungkim. I thought that (to be exact) in Python classes self.example_variable = {{ value }} is an while def function(self, args, kwargs)
{{ function code }} is a So classes have both We could be more precise with the statement for sure (thanks @jaeyungkim) so in my view there is still an error in changing to attributes. I'll propose an update. |
@@ -192,7 +192,7 @@ In our example, an *instance* will be the name of particular *person* whose *in | |||
|
|||
In our example, two functions `earn` and `spend` can be applied to the current instance data. | |||
|
|||
Taken together, the instance data and functions are called *methods*. | |||
Taken together, the instance data and functions are called *attributes*. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken together, the instance data and functions are called *attributes*. | |
In a Class, the instance data are called *attributes* and functions are called *methods*. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are also properties
but I don't think we need to mention those.
People probably have different opinions here. Google Gemini says the following: Yes, in Python, a method is an attribute of a class. To be precise, a method is a callable attribute of a class. Let's break down what this means: |
Please feel free to make the call @mmcky , I'll leave it with you. |
Thanks @jstac -- interesting. In that case |
"instance data and functions" together are called attributes, not methods. I believe methods are just the function part.