Re: Interesting things of 'getattr' and 'setattr'

2009-12-15 Thread Stefan Behnel
Red Forks, 15.12.2009 13:19: > I don't know it is a feature, or implement detail: > > >>> class C(object): pass > ... > >>> c = C() > >>> setattr(c, ' ', 3) > >>> getattr(c, ' ') > 3 > >>> setattr(c, 'with blank', 4) > >>> getattr(c, 'with blank') > 4 > > getattr / setattr seems treat any string

Interesting things of 'getattr' and 'setattr'

2009-12-15 Thread Red Forks
I don't know it is a feature, or implement detail: >>> class C(object): pass ... >>> c = C() >>> setattr(c, ' ', 3) >>> getattr(c, ' ') 3 >>> setattr(c, 'with blank', 4) >>> getattr(c, 'with blank') 4 getattr / setattr seems treat any string as attribute name. -- http://mail.python.org/mailman/l