Presentations
Templates
Features
Teams
Pricing
Log in
Sign up
Log in
Sign up
Menu
Python Naming Conventions
General
Avoid using names that are too general or too long. Strike a good balance between the two.
Bad: data_structure, my_list, info_map, storing_vote_count_for_user_approach_link
Good: user_profile, vote_count, upsert_link
Modules/Packages/Functions
Modules/Packages names should be all lower case like
reinforce
When multiple words are needed, an underscore should separate them like
register_hook
,
is_shared
It is usually preferable to stick to short names
Classes
Class names should follow the UpperCaseCamelCase convention like
ContextMixin, TensorBase
Python’s built-in classes, however, are typically lowercase words
Exception classes should end in “Error like
TypeError, ExampleError.
Constants
Constant names must be fully capitalized likes
CACHES
,
SITES
Words in a constant name should be separated by an underscore like
MIDDLEWARE_CLASSES
,
LANGUAGE_CODE
Python Naming Conventions
By Abhyuday Pratap Singh
Made with Slides.com
Python Naming Conventions
718
Abhyuday Pratap Singh
More from
Abhyuday Pratap Singh