Skip to content

Commit f05bad3

Browse files
committed
module naming
1 parent bfeaa95 commit f05bad3

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

docs/writing/structure.rst

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,22 @@ As soon as you use `import` statements you use modules. These can be either buil
7575
modules such as `os` and `sys`, third-party modules you have installed in your
7676
environment, or your project's internal modules.
7777

78-
Nothing special is required for a Python file to be a module, but the import
79-
mechanism needs to be understood in order to use this concept properly and avoid
80-
some issues.
78+
To keep in line with the style guide, keep module names short, lowercase, and
79+
be sure to avoid using special symbols like the dot (.) or question mark (?).
80+
So a file name like `my.spam.py` is one you should try to avoid! Naming this way
81+
will interfere with the way python looks for modules.
82+
83+
In this example python expects to find a "spam.py" file in a folder named "my"
84+
which is not the case. There is an
85+
`example <http://docs.python.org/tutorial/modules.html#packages>`_
86+
of how the dot should be used available in the python docs.
87+
88+
If you'd like you could name it as `my_spam.py` but even our friend the
89+
underscore should not be seen often in module names.
90+
91+
Aside for some naming restrictions, nothing special is required for a Python file
92+
to be a module, but the import mechanism needs to be understood in order to use
93+
this concept properly and avoid some issues.
8194

8295
Concretely, the `import modu` statement will look for the proper file, which is
8396
`modu.py` in the same directory as the caller if it exists. If it is not

0 commit comments

Comments
 (0)