Python naming conventions for modules

I have a module whose purpose is to define a class called “nib”. (and a few related classes too.) How should I call the module itself? “nib”? “nibmodule”? Anything else?

Python naming conventions in decorators

Are there any accepted naming conventions for the innards of Python decorators? The style guide doesn’t mention it, and this awesome entry about decorators is pretty consistent in using variants of

Python naming conventions

I am using Flask-Restful for implementing REST api in my python application. I have a model module, a business module and a controller module. This is one of my controllers defined in a login_controll

Jar file naming conventions

Are there any industry standard conventions for naming jar files?

Python Naming Conventions for Dictionaries/Maps/Hashes

While other questions have tackled the broader category of sequences and modules, I ask this very specific question: What naming convention do you use for dictionaries and why? Some naming conventio

iOS .plist naming conventions

What are the naming conventions when dealing with .plist files in iOS applications. Specifically: Naming conventions for the file names Naming conventions for the keys used Thanks.

Conventions for naming class operations?

What conventions do you use for naming class operations?

PostgreSQL naming conventions

Is anywhere a detailed manual about PostgreSQL naming conventions? (table names vs. camel case, sequences, primary keys, constraints, indexes, etc…)

Python naming conventions for functions that do modify the object or return a modified copy

What would be the naming conventions in Python for functions that can return a modified object or that just modifies the instance. Let’s assume you want to implement both, how you should name the func

PostgreSQL naming conventions

is anywhere a detailed manual about PostgreSQL naming conventions? (table names vs. camel case, sequences-primary key-constraits etc.) thanx!

JsonProperty Naming Conventions

Is there any documentation which details what the JsonProperty naming conventions are? As in if I declare @JsonProperty(id) what can and cannot go inside the parenthesis?


Just nib. Name the class Nib, with a capital N. For more on naming conventions and other style advice, see PEP 8, the Python style guide.

I would call it And I would also name the class Nib.

In a larger python project I’m working on, we have lots of modules defining basically one important class. Classes are named beginning with a capital letter. The modules are named like the class in lowercase. This leads to imports like the following:

from nib import Nib
from foo import Foo
from spam.eggs import Eggs, FriedEggs

It’s a bit like emulating the Java way. One class per file. But with the added flexibility, that you can allways add another class to a single file if it makes sense.

nib is fine. If in doubt, refer to the Python style guide.

From PEP 8:

Package and Module Names 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.

Since module names are mapped to file names, and some file systems are case insensitive and truncate long names, it is important that module names be chosen to be fairly short — this won’t be a problem on Unix, but it may be a problem when the code is transported to older Mac or Windows versions, or DOS.

When an extension module written in C or C++ has an accompanying Python module that provides a higher level (e.g. more object oriented) interface, the C/C++ module has a leading underscore (e.g. _socket).

I know my solution is not very popular from the pythonic point of view, but I prefer to use the Java approach of one module->one class, with the module named as the class. I do understand the reason behind the python style, but I am not too fond of having a very large file containing a lot of classes. I find it difficult to browse, despite folding.

Another reason is version control: having a large file means that your commits tend to concentrate on that file. This can potentially lead to a higher quantity of conflicts to be resolved. You also loose the additional log information that your commit modifies specific files (therefore involving specific classes). Instead you see a modification to the module file, with only the commit comment to understand what modification has been done.

Summing up, if you prefer the python philosophy, go for the suggestions of the other posts. If you instead prefer the java-like philosophy, create a containing class Nib.

foo module in python would be the equivalent to a Foo class file in Java


foobar module in python would be the equivalent to a FooBar class file in Java