Skip to content
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

AboutClassAttributes: Order of definition matters #249

Open
programmer-ke opened this issue Apr 5, 2022 · 0 comments
Open

AboutClassAttributes: Order of definition matters #249

programmer-ke opened this issue Apr 5, 2022 · 0 comments

Comments

@programmer-ke
Copy link

Thanks for this work, I'm discovering nooks and crannies of Python that I wasn't previously aware of.

For the following section, I wanted to point out that what seems to matter is order of definition of the class attributes.

def bark(self):
return "instance bark"
def growl(self):
return "instance growl"
@staticmethod
def bark():
return "staticmethod bark, arg: None"
@classmethod
def growl(cls):
return "classmethod growl, arg: cls=" + cls.__name__

The classmethod and staticmethod are redefining the instance methods. If order of each of bark and growl is flipped, the instance method will redefine the static/class method.

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

No branches or pull requests

1 participant