switching an instance variable between a property and a normal value

Nick Coghlan ncoghlan at iinet.net.au
Sat Jan 8 01:52:03 EST 2005


Steven Bethard wrote:
> where I also accept *args and **kwds when the default value is to be 
> called.  It's certainly doable with a flag, but note that I have to 
> check the flag every time in both __getitem__ and setdefault.

Alternatively, always use a function for the default value, and set _func to 
lambda: x when working by value :)

Cheers,
Nick.


-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net



More information about the Python-list mailing list