Re: getting special from type, not instance (was Re: [Python-Dev] copy confusion)

2005-01-13 Thread Alex Martelli
On 2005 Jan 14, at 00:11, Guido van Rossum wrote: Let's do override descriptors. A Pronouncement!!! And please, someone fix copy.py in 2.3 and 2.4. Sure -- what way, though? The way I proposed in my last post about it? This would do it, right? (From your first post in this conversation according

Re: getting special from type, not instance (was Re: [Python-Dev] copy confusion)

2005-01-13 Thread Guido van Rossum
> > Let's do override descriptors. > > A Pronouncement!!! > > > And please, someone fix copy.py in 2.3 and 2.4. > > Sure -- what way, though? The way I proposed in my last post about it? This would do it, right? (From your first post in this conversation according to gmail:) > Armin's fix was

Re: getting special from type, not instance (was Re: [Python-Dev] copy confusion)

2005-01-13 Thread Alex Martelli
On 2005 Jan 13, at 18:02, Guido van Rossum wrote: ... In all cases, I'm +1 on seeing built-in method objects (PyMethodDescr_Type) become data descriptors ("classy descriptors?" :-). Let's do override descriptors. A Pronouncement!!! And please, someone fix copy.py in 2.3 and 2.4. Sure -- what wa

Re: getting special from type, not instance (was Re: [Python-Dev] copy confusion)

2005-01-13 Thread Phillip J. Eby
At 09:02 AM 1/13/05 -0800, Guido van Rossum wrote: [Armin] > I guess that a name-based hack in type_new() to turn all __*__() methods into > data descriptors would be even more obscure? To the contary, I just realized in this would in fact be the right approach. In particular, any *descriptor* na

Re: getting special from type, not instance (was Re: [Python-Dev] copy confusion)

2005-01-13 Thread Guido van Rossum
> > The descriptor for __getattr__ and other special attributes could > > claim to be a "data descriptor" > > This has the nice effect that x[y] and x.__getitem__(y) would again be > equivalent, which looks good. > > On the other hand, I fear that if there is a standard "metamethod" decorator > (

Re: getting special from type, not instance (was Re: [Python-Dev] copy confusion)

2005-01-13 Thread Phillip J. Eby
At 10:16 AM 1/13/05 +, Armin Rigo wrote: On the other hand, I fear that if there is a standard "metamethod" decorator (named after Phillip's one), it will be misused. Reading the documentation will probably leave most programmers with the feeling "it's something magical to put on methods with

Re: getting special from type, not instance (was Re: [Python-Dev] copy confusion)

2005-01-13 Thread Alex Martelli
On 2005 Jan 12, at 18:59, Guido van Rossum wrote: ... [Alex] Armin's fix was to change: ... [And then proceeds to propose a new API to improve the situation] I wonder if the following solution wouldn't be more useful (since less code will have to be changed). The descriptor for __getattr__ an

Re: getting special from type, not instance (was Re: [Python-Dev] copy confusion)

2005-01-13 Thread Armin Rigo
Hi Guido, On Wed, Jan 12, 2005 at 09:59:13AM -0800, Guido van Rossum wrote: > The descriptor for __getattr__ and other special attributes could > claim to be a "data descriptor" This has the nice effect that x[y] and x.__getitem__(y) would again be equivalent, which looks good. On the other hand

Re: getting special from type, not instance (was Re: [Python-Dev] copy confusion)

2005-01-12 Thread Aahz
On Wed, Jan 12, 2005, Guido van Rossum wrote: > > PS. The term "data descriptor" now feels odd, perhaps we can say "hard > descriptors" instead. Hard descriptors have a __set__ method in > addition to a __get__ method (though the __set__ method may always > raise an exception, to implement a read-o

Re: getting special from type, not instance (was Re: [Python-Dev] copy confusion)

2005-01-12 Thread Phillip J. Eby
At 09:59 AM 1/12/05 -0800, Guido van Rossum wrote: We would need to introduce a new decorator so that classes overriding these methods can also make those methods "data descriptors", and so that users can define their own methods with this special behavior (this would be needed for __copy__, probab

Re: getting special from type, not instance (was Re: [Python-Dev] copy confusion)

2005-01-12 Thread Guido van Rossum
[Alex] > Armin's fix was to change: > > conform = getattr(type(obj), '__conform__', None) > > into: > > for basecls in type(obj).__mro__: > if '__conform__' in basecls.__dict__: > conform = basecls.__dict__['__conform__'] > break > else: > # no

getting special from type, not instance (was Re: [Python-Dev] copy confusion)

2005-01-12 Thread Alex Martelli
Since this bug isn't the cause of Fredrik's problem I'm changing the subject (and keep discussing the specific problem that Fredrik uncovered under the original subject). On 2005 Jan 12, at 05:11, Guido van Rossum wrote: ... I had exactly the same metabug in the pep 246 reference implementat