setattr using invalid attribute names - bug or feature?

Peter Hansen peter at engcorp.com
Mon Jun 14 10:35:21 EDT 2004


Gerson Kurz wrote:

> I stumbled across this (while using my homebrewn enum class):
> 
>     class test:
>         pass
> 
>     instance = test()
>     setattr(instance, "THIS :*2+~# IS OBVIOUSLY INVALID", 123)
> 
> I would've expected some kind of error message here when calling
> setattr(); after all, its not a regular attribute?

Okay.  But so what?

-Peter



More information about the Python-list mailing list