[Python-Dev] 2.3b1, and object() (original) (raw)
Guido van Rossum guido@python.org
Wed, 30 Apr 2003 09:59:46 -0400
- Previous message: [Python-Dev] 2.3b1, and object()
- Next message: [Python-Dev] test_logging hangs on Solaris 8 (and 9)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On an unrelated note, I'm curious, what's the difference between an instance of an object, and an instance of an empty class? Calling the object builtin returns an <object object at ...>, which I would expect would function the same as a 'class blah(object): pass', but they do not function similarly at all.
>>> class A(object): pass >>> a = A() >>> a.i = 5 >>> a.i 5 >>> >>> a = object() >>> a.i = 5 Traceback (most recent call last): File "", line 1, in ? AttributeError: 'object' object has no attribute 'i'
Instances of 'object' don't have an instance dict, so they are uncapable of having instance variables. When you use a class statement, instances of the subclass get an instance dict, unless slots is used in that class statement.
--Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] 2.3b1, and object()
- Next message: [Python-Dev] test_logging hangs on Solaris 8 (and 9)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]