/  Technology   /  What is the naming convention in Python for variable and function names?
What is the naming convention in Python for variable and function names?

What is the naming convention in Python for variable and function names?

 

The naming convention for function names should always be lowercase where words separated by underscores as necessary to improve readability. This is known as joined_lower convention

For example:

listofdictionaries()
list_of_dictionaries()

 

The naming convention of the variable names also follows the same convention as function names.

For example:

number= 10
string_demo= “Python for everybody”

 

mixedCase is allowed only in contexts where that’s already the prevailing style (e.g. threading.py), to retain backwards compatibility or to conform to pre-existing conventions to put it in short.

 

mixedCase or more popularly called Camel case is a practice of writing phrases without spaces or punctuation and indicating the separation of words with a single capitalized letter, and the first word starting with either case.

For example:

iPhone.

 

Leave a comment