I have defined a method foo
and a class bar
that has a method foo_bar
in __init__.py
file
dir/
__init__.py
runme.py
Now I want to import __init__.py
from runme.py
I have tried
# in runme.py
from . import foo
foo()
and
import foo
foo()
But neither works. I'm using Python 3.7 and Windows 10 Home
I have read How to import classes defined in __init__.py and done some research.
Python's exception is:
ImportError: attempted relative import with no known parent package
# __ init __.py
def foo():
print("Im Foo")
class bar:
def __init__():
pass
def foo_bar(self):
print("Im Foo_Bar in class bar")