Question about import
ian.g.kelly at gmail.com
Thu Sep 10 16:17:19 CEST 2015
On Thu, Sep 10, 2015 at 1:12 AM, Frank Millman <frank at chagford.com> wrote:
> That makes me wonder if, in my project, I can import all modules inside
> 'start.py', and then just use 'import package_name' inside each module?
You can, but for readability and reuse I think it's better to be
explicit in each module and import the fully qualified module names
that are needed, rather than relying on some other module to import
them for you.
> Another question - I thought that, because aa.py and bb.py are in different
> sub-directories, I would have to set them up as packages by adding
> '__init__.py' to each one, but it works fine without that. What am I
That surprises me also, but I suspect it's because they're
subdirectories of the current working directory rather than packages
found on the sys.path.
More information about the Python-list