ivy icon indicating copy to clipboard operation
ivy copied to clipboard

Discuss package definition file in packaging lesson

Open mdpiper opened this issue 1 year ago • 2 comments

The __init__.py file defines a package and lets us do relative imports. Add a paragraph on this to packaging section of the modules lesson.

mdpiper avatar Sep 08 '23 21:09 mdpiper

I almost was able to get away without talking about this, but it's needed, in particular, for relative imports.

mdpiper avatar Sep 08 '23 21:09 mdpiper

From the Python Tutorial:

The __init__.py files are required to make Python treat directories containing the file as packages. This prevents directories with a common name, such as string, from unintentionally hiding valid modules that occur later on the module search path. In the simplest case, __init__.py can just be an empty file, but it can also execute initialization code for the package...

mdpiper avatar Sep 08 '23 21:09 mdpiper