Renaming __getattribute__ (PEP?)

Discussion in 'Python' started by Henry 'Pi' James, Dec 13, 2004.

  1. I'm pretty sure this must not be a new idea, but it seems no one else
    has voiced their agitation about the name "__getattribute__" so far.
    Its closeness to "__getattr__" is only one thing that irritates tons of
    people, as is apparent through the endless repeating question about the
    difference between the two, and through the fact that every lecture on
    "new classes" in Python feels contrained to explain that difference.
    More importantly, the name "__getattribute__" does not reflect what
    this built-in methode is precisely for, namely "to implement attribute
    accesses for instances of the class" [1]. Thus, as I've been wondering
    the whole time, why is it not called "__accessattr__" instead? That
    would be much clearer and distinctly different to "__getattr__", not to
    mention being in sync with the "attr"-instead-of-"attribute"

    This whole issue seems so obvious and trivial to me that I've in fact
    expected it to be resolved by itself - respectively, by the Python
    language developer community which generally pays so much attention to
    details. Now, after it has failed to happen till now, I feel the strong
    urge to speak it out.

    It this qualified PEP stuff?


    [1] Python Reference Manual (current release), section
    Henry 'Pi' James, Dec 13, 2004
    1. Advertisements

  2. On Sun, 12 Dec 2004 20:32:10 -0800, Henry 'Pi' James wrote:
    > It this qualified PEP stuff?

    I can't imagine how you'd justify breaking the reverse compatibility.

    Maybe Py3K.
    Jeremy Bowers, Dec 13, 2004
    1. Advertisements

  3. Nick Coghlan

    Nick Coghlan Guest

    Henry 'Pi' James wrote:
    > This whole issue seems so obvious and trivial to me that I've in fact
    > expected it to be resolved by itself

    Obvious - arguable
    Trivial - I think so too, but probably not in the way you mean

    The obviousness is arguable because the differences between __getattr__ and
    __getattribute__ are genuinely subtle and changing the name of the latter won't
    alter that. A single attribute access may actually pass through both methods at
    different points in the process. (It could be said that the similarity in names
    is actually advantageous, as it corresponds to the similarity in function)

    Python makes it fairly easy to override attribute access, but it can't eliminate
    the basic complexity of the idea - if you want to override builtin behaviour,
    it's necessary to understand what the builtin behaviour *is* first.

    On the triviality aspect, the amount of work involved in changing the name far
    exceeds any slight aesthetic improvement from a new name. And that's without
    even getting into the issues of backwards compatibility. I'd prefer to see the
    developers making speed improvements or adding to the standard library, rather
    than working on changing the names of special methods.


    Nick Coghlan | | Brisbane, Australia
    Nick Coghlan, Dec 13, 2004
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carlo v. Dango

    properly implementing the __getattribute__()

    Carlo v. Dango, Oct 6, 2003, in forum: Python
    John J. Lee
    Oct 8, 2003
  2. Ruud de Jong
    Shalabh Chaturvedi
    Mar 1, 2004
  3. Daniel =?ISO-8859-1?Q?Sch=FCle?=


    Daniel =?ISO-8859-1?Q?Sch=FCle?=, Jul 12, 2004, in forum: Python
    Peter Hansen
    Jul 12, 2004
  4. Gigi
  5. Sylvain Ferriol

    __getattribute__ for class object

    Sylvain Ferriol, Aug 12, 2005, in forum: Python
    Steven Bethard
    Aug 12, 2005

Share This Page