Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

class method ?

Status
Not open for further replies.

ajikoe

Programmer
Apr 16, 2004
71
ID
Hello,

How can I call or define a class method (method which is called using class name not object name)
For example:

class MyCls:
def Mymethod(self):
print"helo"

I want to call:
MyCls.Mymethod() #it always generate error


Sincerely Yours,
Pujo
 
Read the error, it tells you what you've done wrong and why it won't work. I don't think you can do it, just instantiate an object.

I've personally never understood why people use "class methods" in other languages, unless it's simply because they don't have support for namespaces like python does.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top