Python: variables and inheritance
I think I have some misunderstandings of the usage of "class" and "inheritance' in Python. I'll simplify my question as the followings:

    class A:
        def __init__(self):
            self.data = 100

    class B(A):
        def b(self):
            print self.data

    >>>B().b()
    >>>100

OK, so far so good. However, if I create another class, something goes wrong, which is shown as the following:

    class C(A):
        def c(self, num=self.data):
            print self.data
    
    >>>C().c()
    NameError: name 'self' is not defined

I want to set the default value of 'num' to self.data, which is '100'. Without 'class', it will be much simpler:

    data = 100
    def d(num = data):
        print num

    >>>d()
    >>>100

I've already googled some articles, but still stuck in this problem...
Thanks in advance!


Python: variables and inheritance
===

I think I have some misunderstandings of the usage of "class" and "inheritance' in Python. I'll simplify my question as the followings:

    class A:
        def __init__(self):
            self.data = 100

    class B(A):
        def b(self):
            print self.data

    >>>B().b()
    >>>100

OK, so far so good. However, if I create another class, something goes wrong, which is shown as the following:

    class C(A):
        def c(self, num=self.data):
            print self.data
    
    >>>C().c()
    NameError: name 'self' is not defined

I want to set the default value of 'num' to self.data, which is '100'. Without 'class', it will be much simpler:

    data = 100
    def d(num = data):
        print num

    >>>d()
    >>>100

I've already googled some articles, but still stuck in this problem...
Thanks in advance!

