→Self written Jython packages for ImageJ: Simpler reformulation
== Self written Jython packages for ImageJ ==
On the way to perfectly organize Jython code, [https://docs.python.org/2/tutorial/modules.html#packages packages] are the next step.
In Jython , folders that contain modules are made packages by adding the file <code>__init__.py</code>. This file can be empty. An folder structure can look like this:
The reason for the last import to fail is the empty <code>__init__.py</code>. We have to define which modules of the package are imported when using <code>import *</code>. This is done by setting the variable <code>__all__</code>
at <code>__init__.py</code>. For <code>myPackage2</code> this line of code is needed:
Besides setting this variable, the file can contain normal Jython code that is executed
== Bundle packages in a JAR file ==