csdms / ivy

Course material on scientific software development for researchers in earth and planetary surface processes
https://csdms.colorado.edu
Other
75 stars 58 forks source link

Discuss package definition file in packaging lesson #131

Open mdpiper opened 1 year ago

mdpiper commented 1 year ago

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 commented 1 year ago

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

mdpiper commented 1 year ago

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...