On 05/23/2013 11:13 AM, Éric Araujo wrote:
Thanks for writing this PEP. Blessing one implementation for the stdlib
and one official backport will make programmers’ lives a bit easier :)
>>> @fun.register(int)
... def _(arg, verbose=False):
... if verbose:
... print("Strength in numbers, eh?", end=" ")
... print(arg)
...
Does this work if the implementation function is called like the first
decorated function? (I don’t know the proper terminology) e.g.
>>> @fun.register(int)
... def fun(arg, verbose=False):
... if verbose:
... print("Strength in numbers, eh?", end=" ")
... print(arg)
The precedent is 2.6+ properties, where prop.setter mutates and returns
the property object, which then overwrites the previous name in the
class dictionary.
Actually, properties return new instances:
--> class Test(object):
... _temp = 'fleeting'
... @property
... def temp(self):
... return self._temp
... @temp.setter
... def new_temp(self, value):
... self._temp = value
...
--> id(Test.temp)
30245384
--> id(Test.new_temp)
30246352
--> Test.temp is Test.new_temp
False
--
~Ethan~
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com