Class is not defined despite being imported

class, module, python

Solution

Use the fully-qualified name:

sayinghi = testmodule.Greeter("hello world!")

There is an alternative form of `import` that would bring `Greeter` into your namespace:

from testmodule import Greeter

Problem

I seem to have run into a really confusing error. Despite importing the .py file containing my class, Python is insistent that the class doesn't actually exist. Class definition in testmodule.py: ``` class Greeter: def __init__(self, arg1=None): self.text = arg1 def say_hi(self): return self.text ``` main.py: ``` #!/usr/bin/python import testmodule sayinghi = Greeter("hello world!") print(sayinghi.say_hi()) ``` I have a theory that the import is not working as it should. How do I do this correctly?

Original source