[ python-Bugs-1419989 ] class dictionary shortcircuits __getattr__

SourceForge.net noreply at sourceforge.net
Tue Jan 31 08:08:08 CET 2006


Bugs item #1419989, was opened at 2006-01-31 02:08
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1419989&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Shaun Cutts (shauncutts)
Assigned to: Nobody/Anonymous (nobody)
Summary: class dictionary shortcircuits __getattr__

Initial Comment:
page 3.3.2 of Language Reference states:

"....Note that at least for instance variables, you 
can fake total control by not inserting any values in 
the instance attribute dictionary (but instead 
inserting them in another object)."

A counterexample (doctest style):
-----------------------------
>>> class Foo:
...     bar = None
...     def __getattr__( self, attr ):
...         return 'boo'
...
>>> f = Foo()
>>> print "bar: ",f.bar
bar: None
------------------------------
'bar' in class dictionary (not just in instance 
dictionary) also causes __getattr__ not to be called.

BTW.. above in the doc, it says that __getattr__ 
called only if "normal methods" can't find attribute. 
So this would seem a documentation bug. 

However, right now at least, I would prefer if the 
instance dictionary alone were decisive.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1419989&group_id=5470


More information about the Python-bugs-list mailing list