Re: [Python-Dev] Let's get rid of unbound methods

2013-06-04 Thread Steven D'Aprano
On 04/06/13 12:43, 探晴 wrote: Your email appears to be blank, except for a large chunk of HTML code. Did you have something specific to say other than the subject line? As for unbound methods, Guido's time machine strikes again. They're already gone in Python 3. py> class X: ... def sp

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-28 Thread Greg Ewing
Tim Peters wrote: I expect that's because he stopped working on Zope code, so actually thinks it's odd again to see a gazillion methods like: class Registerer(my_base): def register(*args, **kws): my_base.register(*args, **kws) I second that! My PyGUI code is *full* of __init__ methods

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-28 Thread Greg Ewing
Josiah Carlson wrote: While it seems that super() is the 'modern paradigm' for this, I have been using base.method(self, ...) for years now, and have been quite happy with it. I too would be very disappointed if base.method(self, ...) became somehow deprecated. Cooperative super calls are a differe

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-05 Thread Armin Rigo
Hi Phillip, On Wed, Jan 05, 2005 at 01:03:42PM -0500, Phillip J. Eby wrote: > >Is there any other use case for 'C.x' not returning the same as > >'appropriate_super_class_of_C.__dict__["x"]' ? > > Er, classmethod would be one; a rather important one at that. Oups. Right, sorry. Armin

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-05 Thread Guido van Rossum
> Um, isn't all this stuff going to be more complicated and spread out over > more of the code than just leaving unbound methods in place? Well, in an early version of Python it was as simple as I'd like ot to be again: the instancemethod type was only used for bound methods (hence the name) and C

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-05 Thread Phillip J. Eby
At 12:29 PM 1/5/05 -0500, Barry Warsaw wrote: On Wed, 2005-01-05 at 10:41, Glyph Lefkowitz wrote: > I think it would be reasonable to assign im_class only to functions > defined in class scope. The only serialization that would break in that > case is if your example had a 'del f' at the end. +1.

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-05 Thread Phillip J. Eby
At 04:30 PM 1/5/05 +, Armin Rigo wrote: Hi Guido, On Tue, Jan 04, 2005 at 10:28:03AM -0800, Guido van Rossum wrote: > Let's get rid of unbound methods. Is there any other use case for 'C.x' not returning the same as 'appropriate_super_class_of_C.__dict__["x"]' ? Er, classmethod would be one; a

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-05 Thread Jim Fulton
Armin Rigo wrote: Hi Jim, On Tue, Jan 04, 2005 at 02:44:43PM -0500, Jim Fulton wrote: Actually, unbound builtin methods are a different type than bound builtin methods: Of course, but conceptually they are similar. You would still encounter the concept if you got an unbound builtin method. There

RE: [Python-Dev] Let's get rid of unbound methods

2005-01-05 Thread Andrew Koenig
> duck typing? That's the Australian pronunciation of "duct taping". ___ 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-arc

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-05 Thread Barry Warsaw
On Wed, 2005-01-05 at 10:41, Glyph Lefkowitz wrote: > I think it would be reasonable to assign im_class only to functions > defined in class scope. The only serialization that would break in that > case is if your example had a 'del f' at the end. +1. If you're doing something funkier, then you

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-05 Thread Barry Warsaw
On Wed, 2005-01-05 at 10:37, Glyph Lefkowitz wrote: > One approach I have taken in order to avoid copiously over-documenting > every super() using class is to decouple different phases of > initialization by making __init__ as simple as possible (setting a few > attributes, resisting the temptatio

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-05 Thread Shane Holloway (IEEE)
Alex Martelli wrote: def f(*a): pass class C(object): pass class D(object): pass C.f = D.f = f If now we want C.f.im_class to differ from D.f.im_class then we need f to get copied implicitly when it's assigned to C.f (or, of course, when C.f is accessed... but THAT might be substantial overhead).

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-05 Thread Armin Rigo
Hi Guido, On Tue, Jan 04, 2005 at 10:28:03AM -0800, Guido van Rossum wrote: > Let's get rid of unbound methods. Is there any other use case for 'C.x' not returning the same as 'appropriate_super_class_of_C.__dict__["x"]' ? I guess it's too late now but it would have been nice if user-defined __g

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-05 Thread Armin Rigo
Hi Jim, On Tue, Jan 04, 2005 at 02:44:43PM -0500, Jim Fulton wrote: > >Actually, unbound builtin methods are a different type than bound > >builtin methods: > > Of course, but conceptually they are similar. You would still > encounter the concept if you got an unbound builtin method. There are

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-05 Thread Glyph Lefkowitz
On Wed, 2005-01-05 at 12:11 +0100, Alex Martelli wrote: > Hmmm, seems to me we'd need copies of the function object for this > purpose: For the stated use-case of serialization, only one copy would be necessary, and besides - even *I* don't use idioms as weird as the one you are suggesting very

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-05 Thread Glyph Lefkowitz
On Tue, 2005-01-04 at 22:12 -0500, Bob Ippolito wrote: > If you have a class hierarchy where this is a problem, it's probably > pretty fragile to begin with, and you should think about making it > simpler. I agree with James's rant almost entirely, but I like super() anyway. I think it is an in

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-05 Thread Alex Martelli
On 2005 Jan 05, at 04:42, Barry Warsaw wrote: On Tue, 2005-01-04 at 18:01, Jack Jansen wrote: But I'm more worried about losing the other information in an unbound method, specifically im_class. I would guess that info is useful to class browsers and such, or are there other ways to get at that? Th

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Josiah Carlson
Tim Peters <[EMAIL PROTECTED]> wrote: > > [Tim Peters] > >> ... Unbound methods are used most often (IME) to call a > >> base-class method from a subclass, like > >> my_base.the_method(self, ...). > >> It's especially easy to forget to write `self, ` there, and the > >> exception msg then is qu

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Barry Warsaw
On Tue, 2005-01-04 at 18:01, Jack Jansen wrote: > But I'm more worried about losing the other information in an unbound > method, specifically im_class. I would guess that info is useful to > class browsers and such, or are there other ways to get at that? That would be my worry too. OTOH, we

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Bob Ippolito
On Jan 4, 2005, at 8:18 PM, Josiah Carlson wrote: Tim Peters <[EMAIL PROTECTED]> wrote: Guido wrote: Let's get rid of unbound methods. When class C defines a method [snip] Really? Unbound methods are used most often (IME) to call a base-class method from a subclass, like my_base.the_method(self, .

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Tim Peters
[Tim Peters] >> ... Unbound methods are used most often (IME) to call a >> base-class method from a subclass, like >> my_base.the_method(self, ...). >> It's especially easy to forget to write `self, ` there, and the >> exception msg then is quite focused because of that extra bit of >> type check

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Josiah Carlson
Tim Peters <[EMAIL PROTECTED]> wrote: > Guido wrote: > > Let's get rid of unbound methods. When class C defines a method [snip] > Really? Unbound methods are used most often (IME) to call a > base-class method from a subclass, like my_base.the_method(self, ...). > It's especially easy to forget

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Bob Ippolito
On Jan 4, 2005, at 6:01 PM, Jack Jansen wrote: On 4-jan-05, at 19:28, Guido van Rossum wrote: The extra type checking on the first argument that unbound methods are supposed to provide is not useful in practice (I can't remember that it ever caught a bug in my code) It caught bugs for me a couple

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Jack Jansen
On 4-jan-05, at 19:28, Guido van Rossum wrote: The extra type checking on the first argument that unbound methods are supposed to provide is not useful in practice (I can't remember that it ever caught a bug in my code) It caught bugs for me a couple of times. If I remember correctly I was callin

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Phillip J. Eby
At 11:40 AM 1/4/05 -0800, Guido van Rossum wrote: [Jim] > We'll still need unbound builtin methods, so the concept won't > go away. In fact, the change would mean that the behavior between > builtin methods and python methods would become more inconsistent. Actually, unbound builtin methods are a d

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Jp Calderone
On Tue, 4 Jan 2005 12:18:15 -0800, Guido van Rossum <[EMAIL PROTECTED]> wrote: >[me] > > > Actually, unbound builtin methods are a different type than bound > > > builtin methods: > > [Jim] > > Of course, but conceptually they are similar. You would still > > encounter the concept if you got an u

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Guido van Rossum
[me] > > Actually, unbound builtin methods are a different type than bound > > builtin methods: [Jim] > Of course, but conceptually they are similar. You would still > encounter the concept if you got an unbound builtin method. Well, these are all just implementation details. They really are all

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Jp Calderone
On Tue, 04 Jan 2005 20:02:06 GMT, Jp Calderone <[EMAIL PROTECTED]> wrote: >On Tue, 4 Jan 2005 10:28:03 -0800, Guido van Rossum <[EMAIL PROTECTED]> wrote: > >In my blog I wrote: > > > > Let's get rid of unbound methods. When class C defines a method f, C.f > > should just return the function object

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Jp Calderone
On Tue, 4 Jan 2005 10:28:03 -0800, Guido van Rossum <[EMAIL PROTECTED]> wrote: >In my blog I wrote: > > Let's get rid of unbound methods. When class C defines a method f, C.f > should just return the function object, not an unbound method that > behaves almost, but not quite, the same as that func

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Jim Fulton
Guido van Rossum wrote: [Jim] We'll still need unbound builtin methods, so the concept won't go away. In fact, the change would mean that the behavior between builtin methods and python methods would become more inconsistent. Actually, unbound builtin methods are a different type than bound builti

RE: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Raymond Hettinger
[Guido van Rossum] > > Let's get rid of unbound methods. +1 [Jim Fulton] > duck typing? Requiring a specific interface instead of a specific type. [Guido] > > Does anyone think this is a bad idea? [Jim] > It *feels* very disruptive to me, but I'm probably wrong. > We'll still need unbound

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Guido van Rossum
[Jim] > We'll still need unbound builtin methods, so the concept won't > go away. In fact, the change would mean that the behavior between > builtin methods and python methods would become more inconsistent. Actually, unbound builtin methods are a different type than bound builtin methods: >>> ty

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Jim Fulton
Phillip J. Eby wrote: At 10:28 AM 1/4/05 -0800, Guido van Rossum wrote: Of course, more changes would be needed: docs, the test suite, and some simplifications to the instance method object implementation in classobject.c. Does anyone think this is a bad idea? Code that currently does 'aClass.aMet

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Tim Peters
[Guido] > In my blog I wrote: > > Let's get rid of unbound methods. When class C defines a method > f, C.f should just return the function object, not an unbound > method that behaves almost, but not quite, the same as that > function object. The extra type checking on the first argument that > un

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Phillip J. Eby
At 01:36 PM 1/4/05 -0500, Jim Fulton wrote: duck typing? AKA latent typing or, "if it walks like a duck and quacks like a duck, it must be a duck." Or, more pythonically: if hasattr(ob,"quack") and hasattr(ob,"duckwalk"): # it's a duck This is as distinct from both 'if isinstance(ob,D

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Phillip J. Eby
At 10:28 AM 1/4/05 -0800, Guido van Rossum wrote: Of course, more changes would be needed: docs, the test suite, and some simplifications to the instance method object implementation in classobject.c. Does anyone think this is a bad idea? Code that currently does 'aClass.aMethod.im_func' in order t

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Aahz
On Tue, Jan 04, 2005, Jim Fulton wrote: > Guido van Rossum wrote: >> >> and the overloading of >>unbound and bound methods on the same object type is confusing. Also, >>the type checking offered is wrong, because it checks for subclassing >>rather than for duck typing. > > duck typing? "If it loo

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Jack Diederich
On Tue, Jan 04, 2005 at 10:28:03AM -0800, Guido van Rossum wrote: > In my blog I wrote: > > Let's get rid of unbound methods. When class C defines a method f, C.f > should just return the function object, not an unbound method that > behaves almost, but not quite, the same as that function object.

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Bob Ippolito
On Jan 4, 2005, at 1:28 PM, Guido van Rossum wrote: Let's get rid of unbound methods. When class C defines a method f, C.f should just return the function object, not an unbound method that behaves almost, but not quite, the same as that function object. The extra type checking on the first argumen

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-04 Thread Jim Fulton
Guido van Rossum wrote: In my blog I wrote: Let's get rid of unbound methods. When class C defines a method f, C.f should just return the function object, not an unbound method that behaves almost, but not quite, the same as that function object. The extra type checking on the first argument that u