Fomalhaut
Fomalhaut

Reputation: 9785

Names of modules in PEP8

According to PEP8 (or another reputable convention), am I allowed to name a python module as MyCoolClass if it contains a class?

class MyCoolClass:
    ...

It is supposed to use this module to import this class only, nothing else. If not, what is the best way to name the module?

Please, provide necessary proof links.

Upvotes: 0

Views: 1560

Answers (1)

iFlo
iFlo

Reputation: 1494

From the Python Software Foundation website (about PEP8):

For Module

Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. Python packages should also have short, all-lowercase names, although the use of underscores is discouraged.

For Classes

Class names should normally use the CapWords convention.

For your particular case

If your class is called Foo, you will call your module just "foo" all lowercase. For more on naming conventions and other style advice, see PEP 8, the Python style guide.

Upvotes: 3

Related Questions