By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,767 Members | 1,053 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,767 IT Pros & Developers. It's quick & easy.

proposal, change self. to .

P: n/a
how about changing the precious self. to .
imagine

self.update()

..update()

simple right?
Aug 3 '08 #1
Share this Question
Share on Google+
6 Replies

P: n/a
Am 03.08.2008, 12:51 Uhr, schrieb Equand <eq****@gmail.com>:
how about changing the precious self. to .
imagine

self.update()

.update()

simple right?
What about:

class x:

def x(self,ob):
ob.doSomethingWith(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.
Aug 3 '08 #2

P: n/a
-----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):pass, 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 <eq****@gmail.com>:
>how about changing the precious self. to .
imagine

self.update()

.update()

simple right?

What about:

class x:

def x(self,ob):
ob.doSomethingWith(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

iEYEARECAAYFAkiVqEcACgkQLMI5fndAv9j8KgCgmS2e+bTOT+ sUPLYhtHBOVlyq
kxwAn028YSOGYGB4RyHZxYq6n4+tsSd+
=vH9d
-----END PGP SIGNATURE-----
Aug 3 '08 #3

P: n/a
In article <Vp******************************@earthlink.com> ,
Nick Dumas <dr******@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):pass, 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 <eq****@gmail.com>:
how about changing the precious self. to .
imagine

self.update()

.update()

simple right?
What about:

class x:

def x(self,ob):
ob.doSomethingWith(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

iEYEARECAAYFAkiVqEcACgkQLMI5fndAv9j8KgCgmS2e+bTOT+ sUPLYhtHBOVlyq
kxwAn028YSOGYGB4RyHZxYq6n4+tsSd+
=vH9d
-----END PGP SIGNATURE-----
--
David C. Ullrich
Aug 5 '08 #4

P: n/a
Heiko Wundram:
how about changing the precious self. to .
imagine
self.update()
.update()
simple right?
I suggest you to start using Ruby instead.

Bye,
bearophile
Aug 5 '08 #5

P: n/a
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):pass, 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.
Aug 5 '08 #6

P: n/a
On Aug 3, 4:10 am, "Heiko Wundram" <modeln...@modelnine.orgwrote:
Am 03.08.2008, 12:51 Uhr, schrieb Equand <equ...@gmail.com>:
how about changing the precious self. to .
imagine
self.update()
.update()
simple right?

What about:

class x:

def x(self,ob):
ob.doSomethingWith(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.
Aug 5 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.