Do I always have to write "self." ?
Samuel A. Falvo II
kc5tja at garnet.armored.net
Fri Apr 28 07:58:00 EDT 2000
In article <280420000746597329%pecora at anvil.nrl.navy.mil>, Louis M. Pecora
wrote:
>> You *can* use another word for 'self' though, 's' or 'me' or something. But
>> it makes your code harder to read, of course...
>
>You mean by doing something like
No. He means something like this:
>>> class Foo:
... def MyMethod( m, arg1, arg2 ):
... m.field1 = arg1
... m.field2 = arg2/arg1
`self' is just an argument, like any other on the list. It's distinguished
*only* in that it's supplied by the Python environment automatically; what
you choose to call it is entirely up to you.
Use of the word `self' is entirely for conventional reasons.
--
KC5TJA/6, DM13, QRP-L #1447
Samuel A. Falvo II
Oceanside, CA
More information about the Python-list
mailing list