Re: Reasoning behind 'self' parameter in classes?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brett g Porter

    Re: Reasoning behind 'self' parameter in classes?

    Robert Dailey wrote:
    This is an example of a response I'm looking for:
    "The self parameter is required because the parser is a bit old and
    needs to know the exact object you're referencing"
    >
    This is _not_ an example of what I'm looking for:
    "Specifying self is a great mysterious thing that we should never
    question. Do not question the language! The language is mighty! Don't
    bring C++ to Python!"
    >
    Fredrik Lundh has written a very clear explanation of this at


    (or http://bit.ly/3EUiCf if you don't feel like stitching that URL back
    together...)

  • bearophileHUGS@lycos.com

    #2
    Re: Reasoning behind 'self' parameter in classes?

    Brett g Porter:
    Fredrik Lundh has written a very clear explanation of this athttp://effbot.org/pyfaq/why-must-self-be-used-explicitly-in-method-de...
    Today lot of people know that Ruby exists, so such FAQ explanation
    must explain why Python doesn't use a shorter syntax like for example
    @foo to denote instance attributes (and maybe @@baz for the class
    attributes).

    Bye,
    bearophile

    Comment

    Working...