By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,527 Members | 1,192 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,527 IT Pros & Developers. It's quick & easy.

Renaming __getattribute__ (PEP?)

P: n/a
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

Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
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.

Jul 18 '05 #2

P: n/a
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 | nc****** | Brisbane, Australia
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.