0% found this document useful (0 votes)
16 views

Python Naming Conventions

The document discusses various Python naming conventions: 1. Camel case, snake case, Pascal case, and kebab case are the four main naming conventions. Camel case capitalizes internal words, snake case uses underscores, Pascal case capitalizes the first letter of each word, and kebab case uses hyphens. 2. Specific conventions are recommended for different code elements in Python: package and module names use all lowercase, class names use CapWords, exception names use suffixes like "Error", function names use mixedCase, and constants are in ALL_CAPS. 3. Method names, instance variables, and function names follow the same rules, while constants, modules, and packages have

Uploaded by

TechLake
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Python Naming Conventions

The document discusses various Python naming conventions: 1. Camel case, snake case, Pascal case, and kebab case are the four main naming conventions. Camel case capitalizes internal words, snake case uses underscores, Pascal case capitalizes the first letter of each word, and kebab case uses hyphens. 2. Specific conventions are recommended for different code elements in Python: package and module names use all lowercase, class names use CapWords, exception names use suffixes like "Error", function names use mixedCase, and constants are in ALL_CAPS. 3. Method names, instance variables, and function names follow the same rules, while constants, modules, and packages have

Uploaded by

TechLake
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

@TRRaveendra

Python Naming Conventions


@TRRaveendra

Python naming conventions can be managed in four ways.

1.Camel Case
2.Snake Case
3.Pascal Case
4.Kebab Case
Camel CASE @TRRaveendra

1.In camel case, you start a name with a small letter.


2.If the name has multiple words, the later words will start with a capital letter.
3.In the 1970s and 1980s, medial capitals were adopted as a standard or alternative naming convention for
fi
multi-word identi ers in several programming languages.
Snake CASE @TRRaveendra

1. Names should be small letters in snake case.


2. If the name has multiple words, And All the words should be small letters and you use a
underscore (_) to separate the words.
3. For example, a variable named first_name would be written in snake case. This is also
sometimes referred to as lower snake case.
Pascal CASE @TRRaveendra

CamelCase with the rst letter capitalized is Pascal CASE

fi
Kebab CASE @TRRaveendra

1.Kebab case is similar to snake case.


2.You use a hyphen (-) instead of an underscore (_) to separate the words.
Python Object Naming Conventions @TRRaveendra

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.

Class Names

Almost without exception, class names use the CapWords convention.


Classes for internal use have a leading underscore in addition.

Exception Names

Because exceptions should be classes, the class naming convention


applies here. However, you should use the suf x "Error" on your
exception names (if the exception actually is an error).

Function Names

Function names should be mixedCase.

Method Names and Instance Variables

Use the function naming rules.

Use one leading underscore only for non-public methods and instance
variables.

Constants

Constants are usually de ned on a module level and written in all


capital letters with underscores separating words. Examples include
MAX_OVERFLOW and TOTAL.
fi
fi
A Short List of Libraries Used in Data Engineering @TRRaveendra
@TRRaveendra

Learn
&
Lead

Like Celebrate Support Funny Love Insightful Curious

You might also like