Note about getattr and '.'

Mathias Panzenboeck e0427417 at student.tuwien.ac.at
Tue Nov 21 16:39:09 EST 2006


szport at gmail.com wrote:
> There is an interesting skewness in python:
> 
> class A(object): pass
> 
>>>> a=A()
>>>> setattr(a, '$foo', 17)
>>>> getattr(a, '$foo')
> 17
> 
> But I can't write 
>>>> a.'$foo'
> 

Yes, this is known. I think IronPython uses a specialized dictionary for members, which prohibits 
malformed names. I don't know if there will be such a dictionary in any future CPython version. 
(Would be good.)

	panzi



More information about the Python-list mailing list