Python packages - problems, pitfalls.

Chris Gonnerman chris.gonnerman at
Sun Nov 4 15:54:12 CET 2001

----- Original Message ----- 
From: "Prabhu Ramachandran" <prabhu at>

> Lets say I have a directory 'pkg' that is the root of a package.
> Inside this directory I have a sub-package, called sub.  So its
> something like:
> pkg/
>     sub/
> Now, from b I'd expect to be able to import 'a' straight away.
> Say in I do
> import a
> This will not work!  I know why it happens but shouldn't Python be
> smart enough to avoid such problems?  Why I consider this a major
> problem is that the importing of a sub-package depends on where its
> parent package is!!  So if pkg is no longer the root of the package
> and say its put inside another BigPkg then to make pkg's sub packages
> work you'd have to edit *all* the sub packages and change every
> reference to pkg.a to BigPkg.pkg.a.  This is a huge pain.

Hmm.  I personally can't say that I've ever renested a package to a
deeper level.  Has anyone else had a problem with this?  The closest
I can think of is converting a group of related modules into a package,
and that wasn't all that much work.

More information about the Python-list mailing list