How to structure packages

rantingrick rantingrick at
Wed Sep 7 13:56:53 EDT 2011

On Sep 7, 10:56 am, bclark76 <bclar... at> wrote:
> I'm learning python, and was playing with structuring packages.
> Basically I want to have a package called mypackage that defines a
> number of classes and functions.
> so I create:
> mypackage

Don't tell me you create a module called Stuff that
function in __init__! Also don't name modules MyClass either. Both the
spelling and grammar is incorrect. ALL modules use lowercase (and only
integrate underscores in the most dire of need!)


from geom.transformation import Transformation
from geom.vector3d import Vector3d
from geom.point3d import Point3d

or alternatively:

       from __vector3d import Vector3d
       from __point3d import Point3d
       from __transformation import Transformation

from geom import Transformation
from geom import Vector3d
from geom import Point3d

Although this method can be brittle due to the fact that one buggy
module can break all the imported code in the __init__ module. I
usually opt for specifying the module in the import path.

More information about the Python-list mailing list