A notebook for testing class methods.


In [31]:
class A(object):
    v = {'a': 3}
    @classmethod
    def f(cls):
        print 'In A'

class B(object):
    v = 5
    @classmethod
    def f(cls):
        print 'In B'

In [32]:
a = A()
a.__class__.f()


In A

In [33]:
B.f()


In B

In [34]:
b = B()
b.f()


In B

In [35]:
a.f()


In A

Accessing class variables


In [36]:
print A.v
print B.v


{'a': 3}
5

In [37]:
a.v


Out[37]:
{'a': 3}

In [38]:
b.v


Out[38]:
5

In [39]:
a.__class__.v


Out[39]:
{'a': 3}

In [41]:
x=3

In [ ]:


In [ ]:


In [ ]: