Python 3.1, object, and setattr()

Ethan Furman ethan at stoneleaf.us
Thu Apr 1 09:46:33 EDT 2010


Greetings!

Perhaps I woke up too early this morning, but this behaviour has me baffled:

Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

--> test = object()

--> setattr(test, 'example', 123)
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
AttributeError: 'object' object has no attribute 'example'

Shouldn't setattr() be creating the 'example' attribute?  Any tips 
greatly appreciated!

~Ethan~



More information about the Python-list mailing list