Re: [Python-Dev] Data descriptor doc/implementation inconsistency

2010-01-12 Thread Nick Coghlan
Michael Foord wrote: Note that the behaviour here is still different from that of a data descriptor: with a data descriptor, once it gets shadowed in the instance dictionary, the descriptor is ignored *completely*. The only way to get the descriptor involved again is to eliminate the

Re: [Python-Dev] Data descriptor doc/implementation inconsistency

2010-01-11 Thread Nick Coghlan
Benjamin Peterson wrote: My question is: Is this a doc bug or a implementation bug? If the former, it will be the description of a data descriptor much less consistent, since it will require that a __get__ method be present, too. If the latter, the fix may break some programs relying on the

Re: [Python-Dev] Data descriptor doc/implementation inconsistency

2010-01-11 Thread Michael Foord
On 11/01/2010 21:12, Nick Coghlan wrote: Benjamin Peterson wrote: My question is: Is this a doc bug or a implementation bug? If the former, it will be the description of a data descriptor much less consistent, since it will require that a __get__ method be present, too. If the latter,

[Python-Dev] Data descriptor doc/implementation inconsistency

2010-01-10 Thread Benjamin Peterson
Consider this program: class Descr(object): def __init__(self, name): self.name = name def __set__(self, instance, what): instance.__dict__[self.name] = what class X(object): attr = Descr(attr) x = X() print(x.attr) x.attr = 42 print(x.attr) It gives in output:

Re: [Python-Dev] Data descriptor doc/implementation inconsistency

2010-01-10 Thread Amaury Forgeot d'Arc
Hi, 2010/1/11 Benjamin Peterson benja...@python.org: Consider this program: class Descr(object):    def __init__(self, name):        self.name = name    def __set__(self, instance, what):        instance.__dict__[self.name] = what class X(object):    attr = Descr(attr) x = X()

Re: [Python-Dev] Data descriptor doc/implementation inconsistency

2010-01-10 Thread Benjamin Peterson
2010/1/10 Amaury Forgeot d'Arc amaur...@gmail.com: Quoting the documentation: Normally, data descriptors define both __get__() and __set__(), while non-data descriptors have just the __get__() method. Your example is neither a data descriptor nor a non-data descriptor... See the footnote:

Re: [Python-Dev] Data descriptor doc/implementation inconsistency

2010-01-10 Thread Łukasz Rekucki
Date: Mon, 11 Jan 2010 01:51:09 +0100 From: Amaury Forgeot d'Arc amaur...@gmail.com To: Benjamin Peterson benja...@python.org Cc: Python Dev python-dev@python.org Subject: Re: [Python-Dev] Data descriptor doc/implementation        inconsistency Message-ID