PEP 8 example of 'Function and method arguments'

Martin P. Hellwig mhellwig at xs4all.nl
Mon Mar 13 11:18:16 EST 2006


While I was reading PEP 8 I came across this part:

"""
Function and method arguments
    Always use 'self' for the first argument to instance methods.
    Always use 'cls' for the first argument to class methods.
"""

Now I'm rather new to programming and unfamiliar to some basic concepts 
of OOP. However I wrote most of my classes in the new style way and by 
this I have always used 'self' for the first argument of an Instance 
method, but now I'm unsure what actually the difference is between an 
instance and a class method is and when to use it in which case.

Could somebody please enlighten me (a rtfm/wrong newsgroup is just as 
welcome of course), preferably in a short code example?

TIA

-- 
mph



More information about the Python-list mailing list