1

I have 2 classes in 2 different files:

fileA.py

class A(self):
    def __init__(self):
        pass
    def func_A(self):
        print '10'

fileB.py

import fileA
class B(self):
    def __init__(self):
        pass
    def func_B(self):
            print '10'

if __name__ == '__main__':
    obj = B()
    # Call func_A
    fileA.func_A()

The call to func_A fails.

AttributeError: 'module' object has no attribute 'func_A'

How can I make it work correctly?

1
  • 1
    func_A isn't just in module fileA it's on an instance of class A from module fileA. Commented Nov 27, 2015 at 1:27

1 Answer 1

2

As using class , you should create an instance of Class A.

a = fileA.A()
a.func_A()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.