[Tutor] why "self" in methods?
Chris Lott
chris at chrislott.org
Mon Apr 5 11:13:08 EDT 2004
Alan Gauld wrote:
>>>>>class SomeClass(object):
>>
>>... def sayHello(self):
>>... print "hi, I'm SomeClass"
>>...
>
>
> But sayHello is not unbound in the sense mentioned in the OP
> (which actually may not be the right term!). What I was really
> asking was what use (if any) do methods without a self parameter have?
The OP (me) is completely clueless at the moment, but I was asking about
creating a method such as def noSelf() in your code below:
>>>>class SomeClass(object):
>
> ... def sayHello(self):
> ... print "hi, I'm SomeClass"
> ... def noSelf():
> ... print "I'm selfless"
My original question was why, if it lacked a parameter, it didn't just
automatically take the parameter self... that they can be created but
not used doesn't seem very Pythonic :)
c
--
Chris Lott
More information about the Tutor
mailing list