-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 Answers2

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()

Matthew Franglen
  • 4,441
  • 22
  • 32
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()
mhawke
  • 84,695
  • 9
  • 117
  • 138