module naming conventions

grackle davidhuebel at gmail.com
Mon Jan 14 18:58:49 EST 2008


On Jan 14, 4:47 pm, Ben Finney <bignose+hates-s... at benfinney.id.au>
wrote:
> I'm not sure, but it sounds as though you have yet to discover Python
> module packages <URL:http://www.python.org/doc/essays/packages.html>.
> They allow a hierarchy of modules in directories.

I do use packages.  I mentioned the Java naming conventions because
they were my first thought for solving the problem of name clashes,
and they work well in some non-Java languages.  They don't apply well
to Python, since every top-level module has a unique identity that can
only be specified on one source path.  If two libraries use the same
top-level module name, they can't be used together in the same program
without modifying their source code.

mycompany_mymodulename was just the first solution I thought of that
seemed practical.  The mycompany_ prefix protects me from name clashes
with useful modules I might acquire from elsewhere.  There's still a
chance of accidental name clashes with other developers in my company,
but those can be dealt with.  I'm not forced to share a top-level
module with every other Python project in the company, so I can
develop different projects independently and then import one into the
other, without modifying or merging their source.

Of course, the best convention is probably the predominant one, and
that's my question:  What is the standard way of naming Python
packages?

-David



More information about the Python-list mailing list