__class__ of what

Eric J. Van der Velden ericjvandervelden at gmail.com
Thu Aug 12 09:43:30 EDT 2010


Hello,

I have,

class C:
        n=0
        def __init__(s):
                __class__.n+=1


I do
>>> C()

This is fine. But of what thing I am taking the __class__ of?
I can also do

        @staticmethod
        def p():
                print(__class__.n)

>>> C.p()
1

Thanks,

Eric J.






More information about the Python-list mailing list