Packages and PyKyra

Alex Martelli aleax at
Thu Sep 25 15:58:26 CEST 2003

Robert Clayton wrote:

> In the PyKyra example programs what does the statement:
> "from PyKyra import *"
> I now assume that this represents a Package hierarchy and not the file
> "" as there is none but for Windows 2000 I am unable to determine
> whereor how  the path is represented (registry, environment, etc.).  Any
> suggestions?

I have no idea about what PyKyra is, but:

You can find out what the path is, at any time, by the two statements:

import sys
print sys.path

If you're right in stating there is no file, then the
import may be coming from:
    [b1] a PyKyra.pyc or .pyo bytecode file
    [b2] a PyKyra.pyd or .dll C-coded extension module
    [b3] the file in a PyKyra directory on the path

The only case involving "packages" is [b3] -- that's what a
package _IS_... a directory with an file.

In any case, the "from PyKyra import *" statement gets the
contents listed in the __all__ entry in module PyKyra, or, if
no such entry, then all entries in module PyKyra whose names
do not start with a single underscore character _ .

The usage of "from whatever import *" is generally unadvisable
except perhaps in those rare cases in which module 'whatever'
has been carefully designed to support this.  Personally, I've
lost the habit of "import *" just about entirely -- even for
carefully designed modules such as Tkinter and Numeric, I do
"import Tkinter as Tk" or "import Numeric as N" and then access
their entries explicitly as Tk.Tk, N.array, etc, etc.  I find,
personally, that this makes my programs more maintainable.


More information about the Python-list mailing list