module naming conventions
grackle
davidhuebel at gmail.com
Mon Jan 14 20:03:43 EST 2008
On Jan 14, 6:28 pm, Ben Finney <bignose+hates-s... at benfinney.id.au>
wrote:
> grackle <davidhue... at gmail.com> writes:
> What do you mean by "top-level module", and "the same top-level name"?
> Do you mean "the same fully-qualified name"? If two modules are in
> separate places in the hierarchy, they will have different
> fully-qualified names.
I mean that if I worked at Google (which I don't) and developed
google.search and google.officeapps, they would share the same top-
level name "google". Because of this, if I wanted to use the two in
the same program, they would have to be deployed at the same point in
the source path: if I deployed one set of source at src1/google/
search/etc. and the other at src2/google/officeapps/etc. and added
src1/ and src2/ to my application's Python source path, one of them
would be found and the other not. (Essentially I'd be trying to
create two different modules, both named "google", which is
nonsense.) I would have to put them in the same source directory and
merge the two google/__init__.py files together.
I might as well admit that I already made the same mistake in reverse,
using a single top-level module for my application, which I now want
to split into a group of core application modules and one or more
optional, separately-deployed packages. Since I screwed up the first
time, I figured I'd get advice before attempting to rectify the
situation. My next (slightly more considered, possibly just as naive)
impulse is to turn google.search and google.officeapps into
google_search and google_officeapps, thereby avoiding name clashes
with internal or external projects. (It feels dangerous, not to
mention presumptuous, to put generic names like "search" and
"officeapps" in the global namespace.)
> Release your package as free software on the Cheeseshop
> <URL:http://cheeseshop.python.org/>. If the name you want is already
> taken, pick one that will help users distinguish yours from the
> existing one.
Unfortunately, my company thinks it's their software and not mine :-)
-David
More information about the Python-list
mailing list