manipulating class attributes from a decorator while the class is being defined

Karl-Heinz Ruskowski kayvoo at googlemail.com
Sat Apr 19 17:47:33 EDT 2008


> How can I reach the class attribute `regexps' from within a decorator?
Now, the first way that comes to my mind is simply overloading the class and 
set your regexps variable in your new class. 

The other way is to create an object and set it more manually (obj.regexps = 
['.*']). Which for me is an ugly this to do because the first way is far more 
elegant :) 

-- 
GPG key: 0x04B3BB96
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20080419/87d69af3/attachment-0001.sig>


More information about the Python-list mailing list