Skip to content

Conversation

jaeyungkim
Copy link
Contributor

"instance data and functions" together are called attributes, not methods. I believe methods are just the function part.

"instance data and functions" together are called attributes, not methods. I believe methods are just the function part.
@jstac
Copy link
Contributor

jstac commented Jun 13, 2025

Thanks @jaeyungkim .

This is indeed completely wrong and we appreciate the fix!

@jstac
Copy link
Contributor

jstac commented Jun 13, 2025

@mmcky Could you please merge when ready and perhaps consider republishing?

@mmcky
Copy link
Contributor

mmcky commented Jun 13, 2025

thanks @jstac and @jaeyungkim.

I thought that (to be exact) in Python classes

self.example_variable = {{ value }}

is an attribute

while

def function(self, args, kwargs)
    {{ function code }}

is a method.

So classes have both attributes being variables and data and methods being functions.

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.

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*.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Taken together, the instance data and functions are called *attributes*.
In a Class, the instance data are called *attributes* and functions are called *methods*.

Copy link
Contributor

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.

@jstac
Copy link
Contributor

jstac commented Jun 14, 2025

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:

@jstac
Copy link
Contributor

jstac commented Jun 14, 2025

Please feel free to make the call @mmcky , I'll leave it with you.

@mmcky
Copy link
Contributor

mmcky commented Jun 14, 2025

Thanks @jstac -- interesting. In that case attributes is definitely an improvement. I'll merge this and make live.

@mmcky mmcky merged commit 8973c2e into QuantEcon:main Jun 14, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants