Skip to content

Commit d39c485

Browse files
committed
clarified module naming re: underscores
1 parent 4432d82 commit d39c485

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

docs/writing/structure.rst

+11-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,17 @@ folder named :file:`my` which is not the case. There is an
391391
dot notation should be used in the Python docs.
392392

393393
If you'd like you could name your module :file:`my_spam.py`, but even our
394-
friend the underscore should not be seen often in module names.
394+
friend the underscore should not be seen often in module names. However, using other
395+
characters (spaces or hyphens) in module names will prevent importing
396+
(- is the subtract operator), so try to keep module names short so there is
397+
no need to separate words. And, most of all, don't namespace with underscores, use submodules instead.
398+
399+
.. code-block:: python
400+
401+
# OK
402+
import library.plugin.foo
403+
# not OK
404+
import library.foo_plugin
395405
396406
Aside from some naming restrictions, nothing special is required for a Python
397407
file to be a module, but you need to understand the import mechanism in order

0 commit comments

Comments
 (0)