
Hello, i know this has been discusses very much, i'm sorry, but i can't help it. In a nutshell, the proposal is as follows: 1. Self remains explicit (like it is now). 2. if a class is a subclass of a special class, e.g. named 'selfless', the self parameter is not required and a special variable, named 'this' is provided. For example: class Foo (selfless): def __init__ (x, y): this.x = x ... A patch for 3.0b3 implementing this can be found at http://www-lehre.inf.uos.de/~kklimek/misc/python_slp_8.diff regards, Kilian Klimek

Kilian Klimek wrote:
Why not just do this? class Foo: def __init__ (this, x, y): this.x = x It's fewer characters, it gets rid of the "self" you seem to dread, and it requires no patches or changes of any kind to Python. And most importantly, has no need to introduce any "magic" into the language. Gary Herron

On 27 agu 2008 at 08:46:15, Kilian Klimek <kilian.klimek@googlemail.com> wrote:
I disagree. From "The Zen of Python": Explicit is better than implicit. Readability counts. Special cases aren't special enough to break the rules. There should be one-- and preferably only one --obvious way to do it. Cheers, Cesare

On Wed, Aug 27, 2008 at 9:14 AM, Cesare Di Mauro <cesare.dimauro@a-tono.com>wrote:
no point in discussing this, but ... someone else emailed me this one too and i don't see the point: writing down 'self' as the first paramenter of your method does not make it any more explicit what it means. (If you want to consider readability: even worse, you can name it whatever you want). Saying "your method must accept an extra parameter (which most people call 'self') that carries all object attributes" is hardly any more explicit then saying "there is a special variable (which is always named 'this') that carries all object attributes".

Kilian Klimek wrote:
i know this has been discusses very much,
There is a related discussion on python-ideas right now and was a long discussion on python-list/c.l.p within the last month. And the month before..... Either would have been the place to post this.
i'm sorry, but i can't help it.
???

You can provide selfless class as a class with special metaclass that overloads __new__ and changes signature of each method. Not sure how good is this, but requires no changes to the language and will work as you want. Cheers, fijal On Wed, Aug 27, 2008 at 8:46 AM, Kilian Klimek <kilian.klimek@googlemail.com> wrote:

Maciej Fijalkowski wrote:
Are you advocating this Maciej? ;-) There's an example that does this here: http://www.voidspace.org.uk/python/articles/metaclasses.shtml#the-selfless-m... Michael
-- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/ http://www.trypython.org/ http://www.ironpython.info/ http://www.resolverhacks.net/ http://wwww.theotherdelia.co.uk/

Kilian Klimek wrote:
Why not just do this? class Foo: def __init__ (this, x, y): this.x = x It's fewer characters, it gets rid of the "self" you seem to dread, and it requires no patches or changes of any kind to Python. And most importantly, has no need to introduce any "magic" into the language. Gary Herron

On 27 agu 2008 at 08:46:15, Kilian Klimek <kilian.klimek@googlemail.com> wrote:
I disagree. From "The Zen of Python": Explicit is better than implicit. Readability counts. Special cases aren't special enough to break the rules. There should be one-- and preferably only one --obvious way to do it. Cheers, Cesare

On Wed, Aug 27, 2008 at 9:14 AM, Cesare Di Mauro <cesare.dimauro@a-tono.com>wrote:
no point in discussing this, but ... someone else emailed me this one too and i don't see the point: writing down 'self' as the first paramenter of your method does not make it any more explicit what it means. (If you want to consider readability: even worse, you can name it whatever you want). Saying "your method must accept an extra parameter (which most people call 'self') that carries all object attributes" is hardly any more explicit then saying "there is a special variable (which is always named 'this') that carries all object attributes".

Kilian Klimek wrote:
i know this has been discusses very much,
There is a related discussion on python-ideas right now and was a long discussion on python-list/c.l.p within the last month. And the month before..... Either would have been the place to post this.
i'm sorry, but i can't help it.
???

You can provide selfless class as a class with special metaclass that overloads __new__ and changes signature of each method. Not sure how good is this, but requires no changes to the language and will work as you want. Cheers, fijal On Wed, Aug 27, 2008 at 8:46 AM, Kilian Klimek <kilian.klimek@googlemail.com> wrote:

Maciej Fijalkowski wrote:
Are you advocating this Maciej? ;-) There's an example that does this here: http://www.voidspace.org.uk/python/articles/metaclasses.shtml#the-selfless-m... Michael
-- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/ http://www.trypython.org/ http://www.ironpython.info/ http://www.resolverhacks.net/ http://wwww.theotherdelia.co.uk/
participants (8)
-
Cesare Di Mauro
-
Fredrik Lundh
-
Gary Herron
-
Georg Brandl
-
Kilian Klimek
-
Maciej Fijalkowski
-
Michael Foord
-
Terry Reedy