Why property works only for objects?
Michal Kwiatkowski
ruby at no.spam
Sat Mar 11 14:43:15 EST 2006
Alex Martelli napisał(a):
> First, let's forget legacy-style classes, existing only for backwards
> compatibility, and focus on new-style ones exclusively -- never use
> legacy classes if you can avoid that.
Ok, let's cover only new-style classes in our discussion.
I've read your comments and am on a way of reading your articles. Still,
with my current knowledge I'm trying to write pure python attributes
lookup function. I've failed for example given below:
class C(object):
__dict__ = {}
obj = C()
obj.a = 7
obj.__dict__ = {}
print object.__getattribute__(obj, '__dict__')
print object.__getattribute__(C, '__dict__')
print obj.a # => 7 !!!
First print returns "{}" and the second returns
{'__dict__': {},
'__module__': '__main__',
'__weakref__': <attribute '__weakref__' of 'C' objects>,
'__doc__': None}
Neither of them have "a" attribute. How come obj.a doesn't raise an
exception? Where obj.a is kept?
mk
--
. o . >> http://joker.linuxstuff.pl <<
. . o It's easier to get forgiveness for being wrong
o o o than forgiveness for being right.
More information about the Python-list
mailing list