Good practices¶
PEP = Python Enhancement Proposal
Conventions de nommage¶
Noms à éviter¶
Never use those characters alone as variable names :
l
(L
lowercase)O
(o
capital)I
(i
capital).
The display of those caracters with some fonts might lead to mix them up with 0
or 1
.
Modules and packages names¶
Package : package
Module : module_name
- short names
- only lowercase characters
- may contain underscores
_
- Though packages names may also contain underscores
_
but PEP8 does not recommend it.
Classes names¶
MyClass
With barely no exception, classes names are made of lowercase letters, with the exception of the first letter of each words that constitutes it.
Exceptions names¶
CustomError
As exceptions are classe, they are names according to the same convention. If the exception is an error, they integrate the Error
suffix (SyntaxError`, IndexError
, …)
Variables, object instances, functions and methods¶
function_name
variable_name
Those use all the same convention : lowercase letters with words separated by underscores _
.