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
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
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
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
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
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
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,