[Tutor] object's attributes
spir
denis.spir at free.fr
Fri Jan 2 17:10:59 CET 2009
Can someone explain the following?
============================
class Type(object):
pass
o = Type()
o.a = 1
print o, o.a
print dir(object)
==> ['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__', '__init__', '__new__',
'__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__']
==> no problem
o = object()
o.a = 1
==> AttributeError: 'object' object has no attribute 'a'
================================
Type does not create any additional attribute or member, or what?
Does this mean that the type 'object' has a hidden __slots__ attr?
Then why doesn't Type inherit it, like any attribute?
Denis
------
la vida e estranya
More information about the Tutor
mailing list