[Tutor] Method question?

W W srilyk at gmail.com
Fri May 2 18:55:59 CEST 2008


I'm playing around with pyGTK, and I have a question to see if I'm
understanding things correctly.

Is a method just a function inside a class?

i.e.

def myFunction():
    print "This is a function"

class myClass:
    def myMethod():
        print "This is a method"

and to call:

myFunction()

I tried to call the method via. myClass.myMethod() and
x = myClass
x.myMethod()

but none of those were working... I'll take a look online, but am I
correct that the only difference is that method is a function inside a
class?

Thanks,
Wayne

-- 
To be considered stupid and to be told so is more painful than being
called gluttonous, mendacious, violent, lascivious, lazy, cowardly:
every weakness, every vice, has found its defenders, its rhetoric, its
ennoblement and exaltation, but stupidity hasn't. - Primo Levi


More information about the Tutor mailing list