473,785 Members | 2,714 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Renaming __getattribute_ _ (PEP?)

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"
convention.

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?

Henry

[1] Python Reference Manual (current release), section 3.3.2.1:
http://docs.python.org/ref/new-style...te-access.html

Jul 18 '05 #1
2 1420
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
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.

Cheers,
Nick.

--
Nick Coghlan | nc******@email. com | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.skystorm.net
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3639
by: Ruud de Jong | last post by:
I have the situation where I need to construct the name of a static method, and then retrieve the corresponding function from a class object. I thought I could just use __getattribute__ for this purpose. This works fine if I already have an instantiation of the class, but not when I try this on the class object directly. A bare bones example:
0
6604
by: Gigi | last post by:
Hi, In the Python documentation regarding __getattribute__ (more attribute access for new style classes) it is mentioned that if __getattribute__ is defined __getattr__ will never be called (unless called explicitely). Here is the exact citation: """ The following methods only apply to new-style classes. __getattribute__( self, name)
3
2579
by: Sylvain Ferriol | last post by:
hello when i define __getattribute__ in a class, it is for the class instances but if i want to have a __getattribute__ for class attributes how can i do that ? sylvain
5
2069
by: Stefan Sonnenberg-Carstens | last post by:
Hi there, I'm facing some strange things - but maybe only me is strange - anyway... i wrote the following code: +++ class T(object): def __init__(self,name='',port=80): self.name=name
5
2527
by: Barry Kelly | last post by:
I'm running this version of Python: Python 2.4.3 (#1, May 18 2006, 07:40:45) on cygwin I read in the documentation that these two expressions are interchangeable: x.__getattribute__('name') <==> x.name
4
3324
by: Pedro Werneck | last post by:
Hi all I noticed something strange here while explaining decorators to someone. Not any real use code, but I think it's worth mentioning. When I access a class attribute, on a class with a custom metaclass with a __getattribute__ method, the method is used when acessing some attribute directly with the class object, but not when you do it from the instance.
1
5740
bartonc
by: bartonc | last post by:
Still have to prepend "default" when assigning variables to this class, but it now allows val = inst.vaule:"""Encapuslate a Default Values Object and Config File""" from inspect import getmembers import wx class DefaultValueHolder(object): """Intended for use with wxConfig (or maybe _winreg) to set up and/or get registry key names and values. Name attrs as default*. "default" will be stripped of when reading and...
6
3557
by: Adam Donahue | last post by:
As an exercise I'm attempting to write a metaclass that causes an exception to be thrown whenever a user tries to access 'attributes' (in the traditional sense) via a direct reference. Consider: class X( object ): y = 'private value' def get_y( self ): return self.y
8
1779
by: bukzor | last post by:
I want to make a MixIn class that waits to initialize its super- classes until an attribute of the object is accessed. Not generally useful, but desirable in my case. I've written this, and it works, but would like to take any suggestions you guys have. I've commented out the "delattr" call because it throws an AttributeError (although I don't know why). class LateInitMixIn(object):
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10087
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.