0

I don't understand. I have a class in one python file called "example.py" and in another python file in the same folder on my desktop, i'm running "from example import *"

and i'm trying to use the class but it gives me an error that the example module doesn't exist, or that the class that i'm using is undefined

Not sure how all these dependencies work...

I'm very new to this so please help me, it's holding me back a lot.

NameError: name 'TheClassName' is not defined

user3611
  • 151
  • 2
  • 9
  • 1
    Possible duplicate of [How to import the class within the same directory or sub directory?](https://stackoverflow.com/questions/4142151/how-to-import-the-class-within-the-same-directory-or-sub-directory) – crimson589 Jun 08 '19 at 05:16

1 Answers1

0

Your question reminds me of myself when I was pretty new to Python.

So let's start by some basic guides.

Python's reference guide on Imports and modules

How To Import Modules in Python 3

But to make long story short, I think adding a dot will fix your problem.

from .example import myclass
  • still doesn't work. gives me this error 1 import check ----> 2 from .module import TheClassName 3 ## find_end(item) produces the value in the end field of item 4 ## find_end: TheClassName -> Int 5 def find_end(item): ValueError: Attempted relative import in non-package – user3611 Jun 09 '19 at 03:54