0

I have basic question about python classes. I would like to access
a class member defined in one python file across different files. Here is my code:

I have one python file class_A.py:

class A:

def Hello(self):
    self.a=12
    print "printing A value from class_1",self.a

Here is the code of class_B.py file

import Class_A

def func_B():
   Instance = Class_A.A()
   Instance.Hello()

func_B()

When I execute, it shows:

TypeError: Hello() takes no arguments (1 given).

Basically what I'm trying to do is accessing class members defined in class_A.py
by creating an instance to that class inside the function func_B which is defined
in another python file Class_B.py. Is this right?

4

1 回答 1

3

我认为您的问题在于class A

class A:
    def Hello(self):
        self.a = 12
        print "printing A value from class_1", self.a

旁白:看看PEP8风格指南。

于 2013-04-18T10:03:34.213 回答