Reputation: 573
Sounds trivial, but I'm a beginner. I want to package a project "project", that includes a python file "pyfile", that includes a function "func". Problem is that even though I include a init.py in this way:
project
|-pyfile.py
|-__init__.py
I still need to call the function by
from project import pyfile
pyfile.func()
How do I make the function callable just by
import project
project.func()
Upvotes: 0
Views: 227
Reputation: 382
Simply add
from pyfile import *
to project/__init__.py
and
import project
project.func()
will work
Upvotes: 2