Creating package in Python ???
Gordon McMillan
gmcm at hypernet.com
Sun Jul 29 09:26:16 EDT 2001
Yossi Mor wrote:
> 1. For creating a package I have to create a *.py script that will
> group selected modules and contain the following script __init__.py. ->
> Can you elaborate on this script definition.
__init__.py can be empty (it frequently is). It's presence is needed
to signal that the directory it is in is a package.
> 2. I have tried to create a package that contains 2 modules and
> succeeded in importing the package itself but not a module inside the
> package for example 'import pkg.fib1' - what was wrong ?
Assuming that directory A is on your python path, your package should
look like this:
A/
pkg/
__init__.py
fib1.py
<other modules in your package>
- Gordon
More information about the Python-list
mailing list