Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

AboutClassAttributes: Order of definition matters #249

Copy link
Copy link
@programmer-ke

Description

@programmer-ke
Issue body actions

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.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.