Skip to main content
Home
  • Tutorials
  • SEO
  • AI
    • How to write an AI prompt
    • GenAI Roadmap for Beginners
  • Crypto
  • Web
    • Sample resume
    • Resume builder
    • Download movies for free
    • Download paid sotware for free
  • Python
  • langchain
  • HTML
  • CSS
  • JavaScript
  • Algorithm
  • DSA
  • PHP
  • Docker

Breadcrumb

  1. Home
  2. Python

Code Standards in Python

Profile picture for user admin
By admin , 9 January, 2022

1. Indentation:

The recommendation is to use 4 spaces for indentation.


Blank Lines


In Python scripts, top-level function and classes are separated by two blank lines. 
Method definitions inside classes should be separated by one blank line.

Whitespaces

  • should try to avoid whitespaces in Expressions and Statements.
  • Add blank line before a single line comment
  • Break up sections of code with white space.

Imports

 each import should be on a single line.

 

Source File Encoding

 Python 3 has UTF-8 ,the default source encoding. 

 

2. naming conventions

Variables naming conventions

Use snake_case And All Lower Case

snake case: when words are separated by underscores.

Example: lower_case_with_underscores.

 

Classes naming conventions

use CamelCase for class definitions.


CamelCase: first letter capitalized With Every word.

Example: CapitalizedWords.

 

3.General conventions

  • Capitalize the first letter of a sentence.
  • Capitalize the first letter of someone’s name.
  • Add a space after the end of a sentence.
  • Add a space after each word.

4. use of comments

5. line lengths

6. use of white space

About text formats

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Book navigation

  • Code Standards in Python
  • Installing Python
  • Python Classes
  • Python Conditional structure
  • Python Data Types
  • Python History
  • Python Loops
  • Python Variables
  • Python functions
  • Working with Files
  • Python Comments
  • Configure Python with VS Code
RSS feed
Section
  • Home
  • Features
  • Pricing
  • FAQs
  • About
About
  • Advertise With Us
  • Disclaimer
  • About Us
  • Contact Us
  • Privacy Policy
  • Terms & Conditions
  • Sitemap
Section
  • Home
  • Features
  • Pricing
  • FAQs
  • About
Newsletter signup
The subscriber's email address.
Manage your newsletter subscriptions
Select the newsletter(s) to which you want to subscribe.
Stay informed - subscribe to our newsletter.
Manage existing

© 2022 - 2024 techbrushup.com. All rights reserved.