A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/318259.html below:

getattr

getattrkyaBey at gmail.com kyaBey at gmail.com
Fri Sep 30 12:13:27 EDT 2005
This question is regarding the __getattr__ function defined for every
object.
Consider the following example

Assume that foo is an instance of class Foo, and the following are
references to foo's field "bar" which is an instance of class Bar

a) foo.bar
b) foo.bar.spam - spam is a member of "bar"

I want the above references to be handled by __getattr__. Hence I do
not have an entry for the 'bar' in foo.__dict__

Is there any  way by which the __getattr__(self,attr) method can
determine that in
case a) attr == 'bar' is the final component in the reference unlike in
case b) where attr=='bar' is NOT the ultimate(final) component of
reference and is an intermediate component in the reference.

tia


More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4