Guido's new method definition idea
Aaron Brady
castironpi at gmail.com
Sat Dec 6 07:03:21 EST 2008
On Dec 5, 8:21 pm, "Daniel Fetchinson" <fetchin... at googlemail.com>
wrote:
> Hi folks,
>
> The story of the explicit self in method definitions has been
> discussed to death and we all know it will stay. However, Guido
> himself acknowledged that an alternative syntax makes perfect sense
> and having both (old and new) in a future version of python is a
> possibility since it maintains backward compatibility. The alternative
> syntax will be syntactic sugar for the old one. This blog post of his
> is what I'm talking about:
>
> http://neopythonic.blogspot.com/2008/10/why-explicit-self-has-to-stay...
>
> The proposal is to allow this:
>
> class C:
> def self.method( arg ):
> self.value = arg
> return self.value
>
> instead of this:
>
> class C:
> def method( self, arg ):
> self.value = arg
> return self.value
>
> I.e. explicit self stays only the syntax is slightly different and may
> seem attractive to some.
...
Would it be valid outside class definitions too? (As follows...)
def sequence.shuffle( ):
x= sequence[ 0 ]
sequence[ 0 ]= sequence[ -1 ]
...etc.
shuffle( listA )
Can you still call it by class membership? (As follows...)
C.method( inst, arg )
More information about the Python-list
mailing list