Home >Backend Development >Python Tutorial >How Does Python\'s Variable and Function Naming Differ from C#\'s?
Python's Naming Convention for Variables and Functions
When migrating from C# to Python, one may observe differences in the naming conventions for variables and methods. In C#, camelCase or PascalCase is commonly used, while Python employs snake_case as well.
Snake Case as the Preferred Style
According to Python's PEP 8 style guide for function and variable naming, lowercase with underscores between words is the preferred style:
Deviation from Snake Case
PascalCase
PascalCase, where the first letter of each word is capitalized, is permitted in contexts with existing PascalCase conventions. For example, the threading.py module follows PascalCase for backwards compatibility.
MixedCase
MixedCase is allowed in limited scenarios where it aligns with the prevalent style. However, this convention should be used sparingly and primarily for retaining backwards compatibility.
The above is the detailed content of How Does Python\'s Variable and Function Naming Differ from C#\'s?. For more information, please follow other related articles on the PHP Chinese website!