Why there is a parameter named "self" for classmethod function?

Jianchun Zhou jianchun.zhou at gmail.com
Thu May 7 04:49:33 CEST 2009


Hi, ALL:

I have a sample code as bellow:

#!/usr/bin/env python

class Hello:
    def __init__(self):
        print "Hello __init__"
    @classmethod
    def print_hello(self):
        print "hello"

Hello.print_hello()

If I move "self" parameter of print_hello away, this code fragment won't
work.

I am wondering when Hello.print_hello() executes, what value will "self" be
asigned?


-- 
Best Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090507/07f45e62/attachment.html>


More information about the Python-list mailing list