Am 03.08.2008, 12:51 Uhr, schrieb Equand <equand@gmail.c om>:
how about changing the precious self. to .
imagine
>
self.update()
>
.update()
>
simple right?
What about:
class x:
def x(self,ob):
ob.doSomethingW ith(self)
? Not so simple anymore, isn't it? If you're not trolling, there's
hundreds of reasons why the explicit self is as it is, and it's not going
to go away, just as a thread that produced immense amounts of response
demonstrated around a week ago. Read that, and rethink.
It's also worth noting that you can use a different name for the object
that represents your class. If you did def __init__(foo):p ass, then you
would be able to access the class's objects with foo.objectname. Using
self is simply the recommended standard.
Heiko Wundram wrote:
Am 03.08.2008, 12:51 Uhr, schrieb Equand <equand@gmail.c om>:
>how about changing the precious self. to .
>imagine
>>
>self.update( )
>>
>.update()
>>
>simple right?
>
What about:
>
class x:
>
def x(self,ob):
ob.doSomethingW ith(self)
>
? Not so simple anymore, isn't it? If you're not trolling, there's
hundreds of reasons why the explicit self is as it is, and it's not going
to go away, just as a thread that produced immense amounts of response
demonstrated around a week ago. Read that, and rethink.
>
--- Heiko.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
In article <VpudnQrs_eADNA jVnZ2dnUVZ_gSdn Z2d@earthlink.c om>,
Nick Dumas <drakonik@gmail .comwrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
>
It's also worth noting that you can use a different name for the object
that represents your class. If you did def __init__(foo):p ass, then you
would be able to access the class's objects with foo.objectname. Using
self is simply the recommended standard.
Close, but not quite. "self" is not really the name of the
object, it's just the name of the first parameter. You
can change the name of that parameter any time you want.
If you do this:
class C(object):
def __init__(this, data):
this.data = data
def __str__(me):
return str(me.data)
def double(random):
random.data = random.data*2
c = C('Hello')
print c
c.double()
print c
c.data = 21
c.double()
print c
you see
Hello
HelloHello
42
(If 'self' were the name of the object there'd be no
reason it had to be included in the parameter list for
methods...)
Heiko Wundram wrote:
Am 03.08.2008, 12:51 Uhr, schrieb Equand <equand@gmail.c om>:
how about changing the precious self. to .
imagine
>
self.update()
>
.update()
>
simple right?
What about:
class x:
def x(self,ob):
ob.doSomethingW ith(self)
? Not so simple anymore, isn't it? If you're not trolling, there's
hundreds of reasons why the explicit self is as it is, and it's not going
to go away, just as a thread that produced immense amounts of response
demonstrated around a week ago. Read that, and rethink.
--- Heiko.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
iEYEARECAAYFAki VqEcACgkQLMI5fn dAv9j8KgCgmS2e+ bTOT+sUPLYhtHBO Vlyq
kxwAn028YSOGYGB 4RyHZxYq6n4+tsS d+
=vH9d
-----END PGP SIGNATURE-----
On Aug 3, 5:44 am, Nick Dumas <drako...@gmail .comwrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
>
It's also worth noting that you can use a different name for the object
that represents your class. If you did def __init__(foo):p ass, then you
would be able to access the class's objects with foo.objectname. Using
self is simply the recommended standard.
That is not a problem either. What the OP wanted could apply
regardless of what the first argument is named. In fact, an advantage
of what the OP requested would be that a person reading the code need
not be concerned with the name of the first argument.
On Aug 3, 4:10 am, "Heiko Wundram" <modeln...@mode lnine.orgwrote:
Am 03.08.2008, 12:51 Uhr, schrieb Equand <equ...@gmail.c om>:
>
how about changing the precious self. to .
imagine
>
self.update()
>
.update()
>
simple right?
>
What about:
>
class x:
>
def x(self,ob):
ob.doSomethingW ith(self)
>
? Not so simple anymore, isn't it? If you're not trolling, there's
This is not a problem at all. If the OP got what he wanted, "self"
could still be available just as it is now to do what you suggested
above. That would not need to change.
hundreds of reasons why the explicit self is as it is, and it's not going
to go away, just as a thread that produced immense amounts of response
demonstrated around a week ago. Read that, and rethink.
>
--- Heiko.
Comment