Module Names with . (dots)?

A

activescott

My understanding is that module names must not have a dot in them. For
example, I tried to create a module like scott.appengine.util.py and
put misc utility classes in there. However, python gives the error "No
module named scott.appengine.util". No I've read about packages
(http://docs.python.org/tutorial/modules.html#packages), but packages
appear to require a specific directory structure and several package
initialization files just to create a simple module with "pretty" dot
syntax. Am I missing something?
 
J

John Machin

My understanding is that module names must not have a dot in them. For
example, I tried to create a module like scott.appengine.util.py  and
put misc utility classes in there. However, python gives the error "No
module named scott.appengine.util". No I've read about packages
(http://docs.python.org/tutorial/modules.html#packages), but packages
appear to require a specific directory structure and several package
initialization files just to create a simple module with "pretty" dot
syntax. Am I missing something?

Create a simple module with "pretty" underscore syntax e.g.
scott_appengine_util and move on.
 
C

Chris Rebert

My understanding is that module names must not have a dot in them. For
example, I tried to create a module like scott.appengine.util.py  and
put misc utility classes in there. However, python gives the error "No
module named scott.appengine.util". No I've read about packages
(http://docs.python.org/tutorial/modules.html#packages), but packages
appear to require a specific directory structure and several package
initialization files just to create a simple module with "pretty" dot
syntax. Am I missing something?

I don't think so. As the Zen says, "Flat is better than nested" and
"Simple is better than complex", so there's no need for your
unnecessarily hierarchical name since it's not part of a package;
either go with John's suggestion or rename your module to something
even simpler (e.g. "saeutil").

Cheers,
Chris
 
A

activescott

I don't think so. As the Zen says, "Flat is better than nested" and
"Simple is better than complex", so there's no need for your
unnecessarily hierarchical name since it's not part of a package;
either go with John's suggestion or rename your module to something
even simpler (e.g. "saeutil").

Cheers,
Chris

Okay, thanks for the feedback guys.
 
A

activescott

I don't think so. As the Zen says, "Flat is better than nested" and
"Simple is better than complex", so there's no need for your
unnecessarily hierarchical name since it's not part of a package;
either go with John's suggestion or rename your module to something
even simpler (e.g. "saeutil").

Cheers,
Chris

BTW: I decided to go with 'scottsappengineutil'. I doubt it will
quality me as a zen master but I believe it is progress :)
 
B

bearophileHUGS

activescott:
BTW: I decided to go with 'scottsappengineutil'.

scottsappengineutil is hard to read and understand. The name split
with underscores is more readable:
scott_appengine_util
Or just:
app_engine_util

Bye,
bearophile
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top