See Python PEP 8: Function and Variable Names:

Function names should be lowercase, with words separated by underscores as necessary to improve readability.

Variable names follow the same convention as function names.

mixedCase is allowed only in contexts where that's already the prevailing style (e.g. threading.py), to retain backwards compatibility.

Answer from S.Lott on Stack Overflow
🌐
Python
peps.python.org › pep-0008
PEP 8 – Style Guide for Python Code | peps.python.org
In Python, this style is generally deemed unnecessary because attribute and method names are prefixed with an object, and function names are prefixed with a module name. In addition, the following special forms using leading or trailing underscores are recognized (these can generally be combined with any case convention):
Discussions

coding style - Python file naming convention? - Software Engineering Stack Exchange
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. ... Class names should normally use the CapWords convention. More on softwareengineering.stackexchange.com
🌐 softwareengineering.stackexchange.com
Variable naming conventions
What you describe is called Hungarian Notation. The Wikipedia article has a list of pros and cons. It has (imo thankfully) fallen out of favor, and isn’t used in Python, especially since variables in Python don’t have a type, values do. And you can use type hints to achieve the same thing. More on reddit.com
🌐 r/learnpython
9
6
December 8, 2024
Follow these rules to write PYTHON variables names like a PRO.
You SHOULD separate words with underscores and not spaces. I'll keep using spaces. Works great so far. More on reddit.com
🌐 r/Python
9
0
September 20, 2022
Go to variable names?
i for integer index iteration. Actual descriptive names for other variables, even for scratch code. Too often have I seen scratch code passed to others, committed, or (worst of all) pushed into production. So proper variable names are a habit I try to enforce unless its literally a file I guarantee will be deleted before any other human sets eyes on it. Even then, if I'm summing something up, I'll always called it summed instead of just s. More on reddit.com
🌐 r/Python
132
29
July 23, 2023
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-naming-conventions
Python Naming Conventions - GeeksforGeeks
July 23, 2025 - The importance of Naming Conventions in Python is following. Naming conventions enhance code readability, making it easier for developers to understand the purpose and functionality of variables, functions, classes, and other code elements. Consistent naming conventions contribute to code maintainability. When developers follow a standardized naming pattern, it becomes more straightforward for others to update, debug, or extend the code. Naming conventions are especially important in collaborative coding environments.
🌐
Medium
medium.com › @rowainaabdelnasser › python-naming-conventions-10-essential-guidelines-for-clean-and-readable-code-fe80d2057bc9
Python Naming Conventions: 10 Essential Guidelines for Clean and Readable Code | by Rowaina Abdelnasser | Medium
December 8, 2024 - By convention, constant names are written in uppercase letters with underscores separating words. Defining constants at the module level allows them to be easily accessed and used throughout the project.
🌐
Readthedocs
visualgit.readthedocs.io › en › latest › pages › naming_convention.html
Python Naming Conventions — CodingConvention 0 documentation
When multiple words are needed, an underscore should separate them · It is usually preferable to stick to 1 word names · Class names should follow the UpperCaseCamelCase convention · Python’s built-in classes, however are typically lowercase words · Exception classes should end in “Error” ...
🌐
Python Guides
pythonguides.com › python-naming-conventions
Naming Conventions In Python
November 21, 2024 - Function names should be action-oriented and descriptive, making it clear what they do. Local variables in functions are usually short and simple, while global ones should be more descriptive to avoid conflicts. These practices ensure that code remains clear and easy to follow. Class names in Python follow the PascalCase convention.
Top answer
1 of 2
324

Quoting https://www.python.org/dev/peps/pep-0008/#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.

For classes:

Class names should normally use the CapWords convention.

And function and (local) variable names should be:

lowercase, with words separated by underscores as necessary to improve readability

See this answer for the difference between a module, class and package:

  • A Python module is simply a Python source file, which can expose classes, functions and global variables.
  • A Python package is simply a directory of Python module(s).

So PEP 8 tells you that:

  • modules (filenames) should have short, all-lowercase names, and they can contain underscores;
  • packages (directories) should have short, all-lowercase names, preferably without underscores;
  • classes should use the CapWords convention.

PEP 8 tells that names should be short; this answer gives a good overview of what to take into account when creating variable names, which also apply to other names (for classes, packages, etc.):

  • variable names are not full descriptors;
  • put details in comments;
  • too specific name might mean too specific code;
  • keep short scopes for quick lookup;
  • spend time thinking about readability.

To finish, a good overview of the naming conventions is given in the Google Python Style Guide.

2 of 2
94

Here is a link for different types of Python name conventions:

Type Public Internal
Packages lower_with_under
Modules lower_with_under _lower_with_under
Classes CapWords _CapWords
Exceptions CapWords
Functions lower_with_under() _lower_with_under()
Global/Class Constants CAPS_WITH_UNDER _CAPS_WITH_UNDER
Global/Class Variables lower_with_under _lower_with_under
Instance Variables lower_with_under _lower_with_under
Method Names lower_with_under() _lower_with_under()
Function/Method Parameters lower_with_under
Local Variables lower_with_under

The style guide for Python is based on Guido’s naming convention recommendations.

Find elsewhere
🌐
Real Python
realpython.com › python-pep8
How to Write Beautiful Python Code With PEP 8 – Real Python
February 12, 2024 - What are some key naming conventions in PEP 8?Show/Hide · PEP 8 suggests using lowercase with underscores for functions and variables (snake case), camel case for classes, and uppercase with underscores for constants.
🌐
James Madison University
w3.cs.jmu.edu › spragunr › CS240_F12 › style_guide.shtml
CS240 Python Coding Conventions
July 9, 2021 - In some fonts, these characters are indistinguishable from the numerals one and zero. When tempted to use `l', use `L' instead. Package and Module Names Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. Python ...
🌐
365 Data Science
365datascience.com › blog › tutorials › python tutorials › how to use python naming conventions
How To Use Python Naming Conventions – 365 Data Science
November 21, 2024 - So, here's a brief overview of the most frequently encountered Python naming conventions. We believe you'll find them useful and you should incorporate them into your practice. This is a naming convention in which the name you give is composed of multiple words that are attached to each other in a sensible order, and the first letter of each of these words is capital.
🌐
Pybites
pybit.es › articles › naming_conventions
Python Naming Conventions – Pybites
July 9, 2023 - That was when I discovered the PEP8 Style Guide on python.org. If you have any doubts as to how your code should be laid out, reference this baby and you’ll be on your way. What does it say about naming conventions? Quite a bit actually! For the pupose of this post there, here’s what it says about Function names (also applicable to Methods and Instance ...
🌐
Reddit
reddit.com › r/learnpython › variable naming conventions
r/learnpython on Reddit: Variable naming conventions
December 8, 2024 -

Hey guys. I'm an old school coder from way back, though I haven't done much coding in many years. My experience is primarily with Visual Basic 6 and .NET as well as some C++. I started my coding journey with good old QBASIC on DOS. I've recently decided to take up Python.

In college, I was taught that variables should have names with prefixes indicating their type. For example, a string variable would be named strVariable or an integer would be intVariable and a boolean would be blnVariable or boolVariable so as to be immediately apparent what type the variable is later in the code.

I've noticed that while it is possible to declare python variables with a specific type, nowhere on the Internet have I found any suggestion that this convention is preferred at all for this language despite Python being touted as a readable, English-like language. (As a side note here, Python isn't nearly as English-like as COBOL, which I once convinced my instructor was similar enough to pseudo-code that he decided not to require us to write pseudo-code for our assignments.)

Is this simply an outdated practice and I'm showing my age or is it not necessary in Python specifically for some other reason? I'm very curious about this.

Cheers.

EDIT: Ah, yes. Hungarian notation. I had forgotten that name. Anyways, it appears I'm simply showing my age and it's an outdated practice for various reasons. Thanks guys.

Also, I have another issue I'm struggling with, but I suppose I should make a separate thread for that.

🌐
Techversant Infotech
techversantinfotech.com › python-naming-conventions-points-you-should-know
Python Naming Conventions: Points You Should Know - Techversant Infotech
1 month ago - Let us discuss a few of the major naming convention, best practices and important points everyone should know. ... Avoid names that are too general or wordy. Maintain a good balance between the two. Bad: user_list, dict_to_store_defns_of_a_word, swapNums, moveInts. Good: user_info, word_definitions, swap_numbers, move_integers.
🌐
Real Python
realpython.com › videos › python-naming-conventions
Python Naming Conventions (Video) – Real Python
You said classes should be named FirstLetterOfEachWordCapital, but what do you name a class being passed into a function (def somthing(MyClass): or def somthing(my_class):)? ... For function and method arguments PEP 8 recommends using lowercase words connected by single underscores. For example: class MyClass: pass def something(my_class): # my_class is an instance of MyClass pass · Become a Member to join the conversation. ... Get a Python Cheat Sheet (PDF) and learn the basics of Python, like working with data types, dictionaries, lists, and Python functions:
Published   June 22, 2023
🌐
Real Python
realpython.com › python-double-underscore
Single and Double Underscores in Python Names – Real Python
August 18, 2025 - Python has a few naming conventions that are based on using either a single or double underscore character (_). These conventions allow you to differentiate between public and non-public names in APIs, write subclasses safely, prevent name ...
🌐
Llego
llego.dev › home › blog › naming conventions and best practices for class and object names in python
Naming Conventions and Best Practices for Class and Object Names in Python - llego.dev
July 9, 2023 - Additionally, these key points apply specifically for naming classes and objects in Python: Class names should use the CapWords or UpperCamelCase convention. Object and instance names should use lowercase_with_underscores.
🌐
Rhino
developer.rhino3d.com › guides › rhinopython › python-code-conventions
Rhino - Python Code Conventions
Using coding conventions results in clear, precise, and readable code that is consistent with other language conventions and is intuitive. For the official documentation on Python Syntax, see the Style Guide for Python Code · In Python names are used as identifiers of functions, classes, variables, etc….
🌐
W3Schools
w3schools.com › python › python_variables_names.asp
Python - Variable Names
September 8, 2020 - Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume). ... A variable name cannot be any of the Python keywords. ... myvar = "John" my_var = "John" _my_var = "John" myVar = "John" MYVAR = "John" myvar2 = "John" Try it Yourself » ... Variable names with more than one word can be difficult to read. There are several techniques you can use to make them more readable:
🌐
Stack Abuse
stackabuse.com › python-naming-conventions-for-variables-functions-and-classes
Python Naming Conventions for Variables, Functions, and Classes
August 30, 2023 - This is also known as ... name should clearly indicate what the function does. Python's naming conventions for functions are similar to its conventions for variables....
🌐
GitHub
gist.github.com › etigui › 7600441926e73c3385057718c2fdef8e
Python naming conventions · GitHub
December 23, 2021 - When using CamelCase names, capitalize all letters of an abbreviation (e.g. HTTPServer) ... pyramid_giza = "pyramid of giza" # Public _pyramid_giza = "pyramid of giza" # Protected __pyramid_giza = "pyramid of giza" # Private ... class PyramidGiza(object): def instance_method(self): print(f'Hello from {self.__class__.__name__}') @classmethod def class_method(cls): print(f'Hello from {cls.__name__}') @staticmethod def static_method(): print(f'Hello from {PyramidGiza.static_method.__name__}')