0

I have this simple project structure:

    main
        __init__.py
        animal.py (class Animal)
        sub1
            __init__.py
            cat.py (class Cat)
        sub2
            __init__.py
            dog.py (class Dog)

Each __init__.py file is empty.

So,

  • from dog.py I need to import Animal class

Using this syntax:

from animal import Animal

I got

ImportError: No module named animal
  • from dog.py I need to import Cat class in sub1.cat module

Using this syntax:

from sub1.cat import Cat

I got

ImportError: No module named sub1.cat

How can I do this?

pepperav
  • 527
  • 6
  • 16

0 Answers0