Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Complete code example that demonstrates all PEP-8 rules

Tags:

I want my code to be PEP-8 compliant.
However, reading the PEP8-page everytime I forgot any of the rules is time-consuming. Much faster would be if I had a code example, which demonstrates all PEP-8 rules.

Is there any code example out there which does exactly that?

like image 544
Wolkenarchitekt Avatar asked Jan 13 '12 15:01

Wolkenarchitekt


People also ask

What is PEP8 in Python with example?

PEP 8, sometimes spelled PEP8 or PEP-8, is a document that provides guidelines and best practices on how to write Python code. It was written in 2001 by Guido van Rossum, Barry Warsaw, and Nick Coghlan. The primary focus of PEP 8 is to improve the readability and consistency of Python code.

What are the key rules in PEP 8 while giving indentation?

The rules of PEP 8 says to use 4 spaces per indentation level and also spaces should be preferred over tabs.

What is the Pep 8 class name convention?

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.

How many blank lines does the PEP 8 specification recommend between methods of a particular class?

Surround top-level function and class definitions with two blank lines. Method definitions inside a class are surrounded by a single blank line. Extra blank lines may be used (sparingly) to separate groups of related functions.


1 Answers

Here's a gist which claims to be a cheatsheet:

https://gist.github.com/RichardBronosky/454964087739a449da04

like image 197
John Lehmann Avatar answered Sep 26 '22 20:09

John Lehmann