-1

If I have Main.py

import Test
test = Test()
test.test_func()

And Test.py

class Test:
    def test_func(self):
        print("success")

it throws an error 'module' object is not callable

I have spent hours trying to figure this out. If I put the class in Main.py I can get an instance of the class but I can't get it to work externally.

2
  • 3
    You need to from Test import Test or test = Test.Test(). Yes, you are going to have to learn Python if you want to use it. Commented Jan 29, 2015 at 11:10
  • @jonrsharpe yes, got it.. Commented Jan 29, 2015 at 11:12

2 Answers 2

1

You have imported the Test module but you are constructing the module and not the inner class. Try changing it to test = Test.Test()

Sign up to request clarification or add additional context in comments.

1 Comment

Oh my gosh your the best!!!!!!!!!!!!!! Thank you
1

You need to access the class declared within module Test. Change Main.py to:

import Test
test = Test.Test()
test.test_func()

or

from Test import Test
test = Test()
test.test_func()

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.