Names

Classes, functions and variables should all be given names that express their purpose and intent. Very long names are completely fine to use if this name perfectly expresses what this element is used for in your code. The additional characters one has to type are of no concern nowadays, since our text editors will autocomplete it for us anyway. However, a very short name can also be acceptable, for example if a variable is only relevant in the next two or three lines of code.

The length of a variable, function or class name should be proportional to its importance and the size of the scope it is used in.

Meaningful names

Use names that express the intent of variables, functions and classes.

Do Not!
var = 7  # num days in week
Do
number_of_days_in_week = 7

Encodings

Names should be pronounceable and searchable. Avoid using encodings that are not commonly known (e.g. pdf, xml)

Do Not!
def genymdhms():  # generate year,month,day,minutes,seconds
Do
def generate_timestamp():

Function parameters

When naming function parameters, make sure to communicate their meaning to the users of the function.

Do Not!
def copy_chars(a1, a2):
    for i in range(len(a1)):
        a2[i] = a1[i]
Do
def copy_chars(source, destination):
    for i in range(len(destination)):
        destination[i] = source[i]

Domain specific names

Names should be relevant to the domain of the software. Imagine encountering the name below in a numerical simulation.

Do Not!
def calc_value_at_edge():

While the name of the function above is somewhat expressive, a domain expert will be more familiar with the following name.

Do
def apply_boundary_condition():