Re: switching an instance variable between a property and a normal value

2005-01-07 Thread Nick Coghlan
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

Re: switching an instance variable between a property and a normal value

2005-01-07 Thread Nick Coghlan
Steven Bethard wrote: I'd like to be able to have an instance variable that can sometimes be accessed as a property, and sometimes as a regular value, e.g. something like: If you want the behaviour to be switchable per-instance, you have to go the route of always running through the property mac

Re: switching an instance variable between a property and a normal value

2005-01-07 Thread Steven Bethard
Robert Brewer wrote: Steven Bethard wrote: I'm playing around with a mapping type that uses setdefault as suggested in http://www.python.org/moin/Python3_2e0Suggestions. The default value for a missing key is either a simple value, or a value generated from a function. If it's generated fro

RE: switching an instance variable between a property and a normal value

2005-01-07 Thread Robert Brewer
Steven Bethard wrote: > I'm playing around with a mapping type that uses setdefault > as suggested > in http://www.python.org/moin/Python3_2e0Suggestions. The > default value > for a missing key is either a simple value, or a value > generated from a > function. If it's generated from the f

Re: switching an instance variable between a property and a normal value

2005-01-07 Thread Steven Bethard
Robert Brewer wrote: Steven Bethard wrote: I'd like to be able to have an instance variable that can sometimes be accessed as a property, and sometimes as a regular value, e.g. something like: ... py> c.x is c.x # I'd like this to be False You'd like 'c.x is c.x' to be FALSE? You can't be seri

RE: switching an instance variable between a property and a normal value

2005-01-07 Thread Robert Brewer
Steven Bethard wrote: > I'd like to be able to have an instance variable that can > sometimes be > accessed as a property, and sometimes as a regular value, > e.g. something > like: ... > py> c.x is c.x # I'd like this to be False You'd like 'c.x is c.x' to be FALSE? You can't be serious. Must

switching an instance variable between a property and a normal value

2005-01-07 Thread Steven Bethard
I'd like to be able to have an instance variable that can sometimes be accessed as a property, and sometimes as a regular value, e.g. something like: py> class C(object): ... def usevalue(self, x): ... self.x = x ... def usefunc(self, func, *args, **kwds): ... self._func,