Another try at Python's selfishness

Jean-Paul Calderone exarkun at divmod.com
Fri Feb 3 13:24:48 EST 2006


On 3 Feb 2006 08:58:56 -0800, n.estner at gmx.de wrote:
>> ...
>> Unfortunately, none of this suggests that it's reasonable to have
>>
>> def x.y(z): ...
>>
>> mean the same as
>>
>> def y(x, z): ...
>
>Actually, it shouldn't. The idea was, that
>    def x.y(z): ...
>(explicitly) introduces an unbound method. That's not introducing a new
>conect to python, it's just making the difference between an unbound
>method and a not-bindable function explicit.
>
>Currently, "def(x,y): ..." can mean two different things: In the
>context of a class, it introduces an unbound method, in global or local
>contexts it introduces a function. I don't want to have a new syntax
>for that, I want two different syntaxes for these two different
>meanings.
>

Are you sure you actually understand what's going on?

    Python 2.4.2 (#2, Sep 30 2005, 21:19:01) 
    [GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> def foo(): pass
    ... 
    >>> print type(foo)
    <type 'function'>
    >>> class bar:
    ...     def foo(self): pass
    ...     print type(foo)
    ... 
    <type 'function'>
    >>> print type(bar.foo)
    <type 'instancemethod'>

Jean-Paul



More information about the Python-list mailing list