newbie: self.member syntax seems /really/ annoying
Neil Cerutti
horpner at yahoo.com
Wed Sep 12 12:58:16 EDT 2007
On 2007-09-12, Michele Simionato <michele.simionato at gmail.com> wrote:
>> I see the argument for making self explicit -- what would be
>> wrong with just .a instead of self.a though? That's still
>> explicit but much easier to read. (I think I've seen that
>> somewhere else, is it C#?)
>
> This has been proposed many times. But self is handy because
> you can give a different name to it: for instance it becomes
> cls when you are inside a classmethod.
The treatment of self in the function's parameter list seems to
be the pitfall of any .member shortcut proposal. Most proposals
don't even address that point.
Does it become:
class Foo:
def __init__():
.bar = 40
or
class Foo:
def __init__(.):
.bar = 40
or
class Foo:
def __init__(self):
.bar = 40
I guess the middle one is the most consistent, but it seems
ugly compared to what we have now.
--
Neil Cerutti
More information about the Python-list
mailing list