SlideShare a Scribd company logo
PEP 8- Python 
Coding Style 
DANIEL BAEK
Introduction 
Most people in RPI have taken Computer Science 1 which is now taught 
using Python. 
Computer Science may touch upon Python coding style, but doesn’t 
explain it in full detail. 
Some RCOS Projects use Python. Many potential projects could be 
made with Python. 
PEP 8 is for Python code on Python projects. There is a separate C code 
style convention for Python projects. (I will not be talking about it 
though.)
Word of Caution 
DON’T REINVENT THE WHEEL! 
If the style causes the code less readable, don’t use it! (You might have 
an overall, bigger problem.) 
Be consistent with older code. 
Older versions that were used before the inception of the document 
shouldn’t have to follow this. (But, why are you using old Python?)
Indentation 
Indentation should always be four (4) spaces long. 
For long lines (>79 characters): 
◦ Functional arguments can always be represented by aligning the first letter 
of subsequent lines with the first character of the original line. 
◦ Function calls can use single indents for subsequent lines. 
◦ Function definitions should use double indents for subsequent lines.
Parenthesis and Brackets 
End parenthesis and brackets should be on their own lines. 
End parenthesis and brackets should either be aligned to the first non-whitespace 
character of the last line or with the first non-whitespace 
character of the construct itself.
Tabs or Spaces 
Python 2.x code should always use spaces. 
Python 3.x code can use spaces or tabs. 
◦ To that end, make sure that you are consistent with your tabs and spaces! 
General recommendation is to use spaces.
Line Length 
<79 characters for regular code. 
<72 character for comments and documentations.
Source File Encoding 
UTF-8 ASCII for Python 2.x 
Latin-1 UTF-8 for Python 3.x
Naming Conventions 
Don’t use I’s, O’s, and l’s as single-character variables: 
◦ I’s and l’s are almost indistinguishable. 
◦ O’s and 0’s are also confusing. 
Modules should be all lowercase. Underscores recommended only if it 
makes the name more readable. 
Class names should be in PascalCase. 
Function names and instance variables should be lowercase with 
underscores as necessary. 
Constants should be ALL_CAPITAL_WITH_UNDERSCORES.
Recommendations 
Code should be written in a way that isn’t a disadvantage of other 
implementations of Python. 
When dealing with Boolean operations, use: 
◦ “if/for/while var1 is not None:” 
◦ But not: “if/for/while not var1 is None:” 
Empty sequences return a false, use this fact! 
◦ Rather than “if len(seq)” 
◦ Use “if seq” 
Don’t compare Boolean values using ==. 
Try to avoid the use of magic numbers.
TL;DR Version 
Go to this site for information about PEP8: 
http://legacy.python.org/dev/peps/pep-0008/ 
Go to this site to check your code: http://pep8online.com/
Thanks to: 
Sean O'Sullivan 
Professor Moorthy 
Professor Goldschmidt 
RCOS

More Related Content

What's hot

Python basics
Python basicsPython basics
Python basics
Hoang Nguyen
 
Functions in python
Functions in pythonFunctions in python
Functions in python
colorsof
 
Functions in python
Functions in pythonFunctions in python
Functions in pythonIlian Iliev
 
Python in 30 minutes!
Python in 30 minutes!Python in 30 minutes!
Python in 30 minutes!
Fariz Darari
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
Devashish Kumar
 
Python decorators
Python decoratorsPython decorators
Python decoratorsAlex Su
 
Python functions
Python functionsPython functions
Python functions
Prof. Dr. K. Adisesha
 
Python
PythonPython
Python
Aashish Jain
 
Arrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | EdurekaArrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | Edureka
Edureka!
 
Python Decision Making And Loops.pdf
Python Decision Making And Loops.pdfPython Decision Making And Loops.pdf
Python Decision Making And Loops.pdf
NehaSpillai1
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
Ramish Suleman
 
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Edureka!
 
Python programming : Strings
Python programming : StringsPython programming : Strings
Python programming : Strings
Emertxe Information Technologies Pvt Ltd
 
Basic data structures in python
Basic data structures in pythonBasic data structures in python
Basic data structures in python
Celine George
 
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Edureka!
 
File handling & regular expressions in python programming
File handling & regular expressions in python programmingFile handling & regular expressions in python programming
File handling & regular expressions in python programming
Srinivas Narasegouda
 
Python training
Python trainingPython training
Python training
Kunalchauhan76
 
Operators in python
Operators in pythonOperators in python
Operators in python
Prabhakaran V M
 

What's hot (20)

Python basics
Python basicsPython basics
Python basics
 
Functions in python
Functions in pythonFunctions in python
Functions in python
 
Functions in python
Functions in pythonFunctions in python
Functions in python
 
Python in 30 minutes!
Python in 30 minutes!Python in 30 minutes!
Python in 30 minutes!
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
 
Exceptions in python
Exceptions in pythonExceptions in python
Exceptions in python
 
Python decorators
Python decoratorsPython decorators
Python decorators
 
Python Tutorial Part 2
Python Tutorial Part 2Python Tutorial Part 2
Python Tutorial Part 2
 
Python functions
Python functionsPython functions
Python functions
 
Python
PythonPython
Python
 
Arrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | EdurekaArrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | Edureka
 
Python Decision Making And Loops.pdf
Python Decision Making And Loops.pdfPython Decision Making And Loops.pdf
Python Decision Making And Loops.pdf
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
 
Python programming : Strings
Python programming : StringsPython programming : Strings
Python programming : Strings
 
Basic data structures in python
Basic data structures in pythonBasic data structures in python
Basic data structures in python
 
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
 
File handling & regular expressions in python programming
File handling & regular expressions in python programmingFile handling & regular expressions in python programming
File handling & regular expressions in python programming
 
Python training
Python trainingPython training
Python training
 
Operators in python
Operators in pythonOperators in python
Operators in python
 

Viewers also liked

Python coding standards
Python coding standardsPython coding standards
Python coding standards
Sharad Singla
 
Naming Convention in Python
Naming Convention in PythonNaming Convention in Python
Naming Convention in Python
Tzu-ping Chung
 
Python coding style guild 19 Langue Rule 17 Style Rule
Python coding style guild 19 Langue Rule 17 Style RulePython coding style guild 19 Langue Rule 17 Style Rule
Python coding style guild 19 Langue Rule 17 Style RuleJS Lee
 
Code review on github training ( intermediate )
Code review on github training ( intermediate )Code review on github training ( intermediate )
Code review on github training ( intermediate )JS Lee
 
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
P3 InfoTech Solutions Pvt. Ltd.
 
Software development practices in python
Software development practices in pythonSoftware development practices in python
Software development practices in python
Jimmy Lai
 
Convolutional neural network in practice
Convolutional neural network in practiceConvolutional neural network in practice
Convolutional neural network in practice
남주 김
 
Automation Testing
Automation TestingAutomation Testing
Automation Testing
Sun Technlogies
 
A pixel to-pixel segmentation method of DILD without masks using CNN and perl...
A pixel to-pixel segmentation method of DILD without masks using CNN and perl...A pixel to-pixel segmentation method of DILD without masks using CNN and perl...
A pixel to-pixel segmentation method of DILD without masks using CNN and perl...
남주 김
 
Clean code
Clean codeClean code
Clean code
Arturo Herrero
 
금융 데이터 이해와 분석 PyCon 2014
금융 데이터 이해와 분석 PyCon 2014금융 데이터 이해와 분석 PyCon 2014
금융 데이터 이해와 분석 PyCon 2014
Seung-June Lee
 
Generative adversarial networks
Generative adversarial networksGenerative adversarial networks
Generative adversarial networks
남주 김
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
Nowell Strite
 

Viewers also liked (14)

Python coding standards
Python coding standardsPython coding standards
Python coding standards
 
Naming Convention in Python
Naming Convention in PythonNaming Convention in Python
Naming Convention in Python
 
Python coding style guild 19 Langue Rule 17 Style Rule
Python coding style guild 19 Langue Rule 17 Style RulePython coding style guild 19 Langue Rule 17 Style Rule
Python coding style guild 19 Langue Rule 17 Style Rule
 
Code review on github training ( intermediate )
Code review on github training ( intermediate )Code review on github training ( intermediate )
Code review on github training ( intermediate )
 
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
 
Software development practices in python
Software development practices in pythonSoftware development practices in python
Software development practices in python
 
Convolutional neural network in practice
Convolutional neural network in practiceConvolutional neural network in practice
Convolutional neural network in practice
 
Automation Testing
Automation TestingAutomation Testing
Automation Testing
 
A pixel to-pixel segmentation method of DILD without masks using CNN and perl...
A pixel to-pixel segmentation method of DILD without masks using CNN and perl...A pixel to-pixel segmentation method of DILD without masks using CNN and perl...
A pixel to-pixel segmentation method of DILD without masks using CNN and perl...
 
Clean code
Clean codeClean code
Clean code
 
금융 데이터 이해와 분석 PyCon 2014
금융 데이터 이해와 분석 PyCon 2014금융 데이터 이해와 분석 PyCon 2014
금융 데이터 이해와 분석 PyCon 2014
 
Generative adversarial networks
Generative adversarial networksGenerative adversarial networks
Generative adversarial networks
 
Clean coding-practices
Clean coding-practicesClean coding-practices
Clean coding-practices
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 

Similar to PEP 8

Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming Language
StefanoTermini3
 
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdfPy-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
shetoooelshitany74
 
notwa dfdfvs gf fdgfgh s thgfgh frg reggg
notwa dfdfvs gf fdgfgh  s thgfgh frg regggnotwa dfdfvs gf fdgfgh  s thgfgh frg reggg
notwa dfdfvs gf fdgfgh s thgfgh frg reggg
Godwin585235
 
Python Training Topics
Python Training TopicsPython Training Topics
Python Training Topics
vibrantuser
 
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
Bhavsingh Maloth
 
Introduction-to-Python.pptx
Introduction-to-Python.pptxIntroduction-to-Python.pptx
Introduction-to-Python.pptx
AyushDey1
 
Python Programming 1.pptx
Python Programming 1.pptxPython Programming 1.pptx
Python Programming 1.pptx
Francis Densil Raj
 
CSC2308 - PRINCIPLE OF PROGRAMMING II.pdf
CSC2308 - PRINCIPLE OF PROGRAMMING II.pdfCSC2308 - PRINCIPLE OF PROGRAMMING II.pdf
CSC2308 - PRINCIPLE OF PROGRAMMING II.pdf
AbdulmalikAhmadLawan2
 
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptxa9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
cigogag569
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
primeteacher32
 
Session-1_Introduction to Python.pptx
Session-1_Introduction to Python.pptxSession-1_Introduction to Python.pptx
Session-1_Introduction to Python.pptx
WajidAliHashmi2
 
Python Training in Pune - Ethans Tech Pune
Python Training in Pune - Ethans Tech PunePython Training in Pune - Ethans Tech Pune
Python Training in Pune - Ethans Tech Pune
Ethan's Tech
 
Python for katana
Python for katanaPython for katana
Python for katana
kedar nath
 
Python final presentation kirti ppt1
Python final presentation kirti ppt1Python final presentation kirti ppt1
Python final presentation kirti ppt1
Kirti Verma
 
1.3 Basic coding skills_tupels_sets_controlloops.ppt
1.3 Basic coding skills_tupels_sets_controlloops.ppt1.3 Basic coding skills_tupels_sets_controlloops.ppt
1.3 Basic coding skills_tupels_sets_controlloops.ppt
VGaneshKarthikeyan
 
Python
PythonPython
Python (3).pdf
Python (3).pdfPython (3).pdf
Python (3).pdf
samiwaris2
 
Programming with Python: Week 1
Programming with Python: Week 1Programming with Python: Week 1
Programming with Python: Week 1
Ahmet Bulut
 

Similar to PEP 8 (20)

Os Goodger
Os GoodgerOs Goodger
Os Goodger
 
Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming Language
 
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdfPy-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
 
notwa dfdfvs gf fdgfgh s thgfgh frg reggg
notwa dfdfvs gf fdgfgh  s thgfgh frg regggnotwa dfdfvs gf fdgfgh  s thgfgh frg reggg
notwa dfdfvs gf fdgfgh s thgfgh frg reggg
 
Python Training Topics
Python Training TopicsPython Training Topics
Python Training Topics
 
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
 
Introduction-to-Python.pptx
Introduction-to-Python.pptxIntroduction-to-Python.pptx
Introduction-to-Python.pptx
 
Python Programming 1.pptx
Python Programming 1.pptxPython Programming 1.pptx
Python Programming 1.pptx
 
CSC2308 - PRINCIPLE OF PROGRAMMING II.pdf
CSC2308 - PRINCIPLE OF PROGRAMMING II.pdfCSC2308 - PRINCIPLE OF PROGRAMMING II.pdf
CSC2308 - PRINCIPLE OF PROGRAMMING II.pdf
 
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptxa9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
 
Coding conventions
Coding conventionsCoding conventions
Coding conventions
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Session-1_Introduction to Python.pptx
Session-1_Introduction to Python.pptxSession-1_Introduction to Python.pptx
Session-1_Introduction to Python.pptx
 
Python Training in Pune - Ethans Tech Pune
Python Training in Pune - Ethans Tech PunePython Training in Pune - Ethans Tech Pune
Python Training in Pune - Ethans Tech Pune
 
Python for katana
Python for katanaPython for katana
Python for katana
 
Python final presentation kirti ppt1
Python final presentation kirti ppt1Python final presentation kirti ppt1
Python final presentation kirti ppt1
 
1.3 Basic coding skills_tupels_sets_controlloops.ppt
1.3 Basic coding skills_tupels_sets_controlloops.ppt1.3 Basic coding skills_tupels_sets_controlloops.ppt
1.3 Basic coding skills_tupels_sets_controlloops.ppt
 
Python
PythonPython
Python
 
Python (3).pdf
Python (3).pdfPython (3).pdf
Python (3).pdf
 
Programming with Python: Week 1
Programming with Python: Week 1Programming with Python: Week 1
Programming with Python: Week 1
 

Recently uploaded

May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 

Recently uploaded (20)

May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 

PEP 8

  • 1. PEP 8- Python Coding Style DANIEL BAEK
  • 2. Introduction Most people in RPI have taken Computer Science 1 which is now taught using Python. Computer Science may touch upon Python coding style, but doesn’t explain it in full detail. Some RCOS Projects use Python. Many potential projects could be made with Python. PEP 8 is for Python code on Python projects. There is a separate C code style convention for Python projects. (I will not be talking about it though.)
  • 3. Word of Caution DON’T REINVENT THE WHEEL! If the style causes the code less readable, don’t use it! (You might have an overall, bigger problem.) Be consistent with older code. Older versions that were used before the inception of the document shouldn’t have to follow this. (But, why are you using old Python?)
  • 4. Indentation Indentation should always be four (4) spaces long. For long lines (>79 characters): ◦ Functional arguments can always be represented by aligning the first letter of subsequent lines with the first character of the original line. ◦ Function calls can use single indents for subsequent lines. ◦ Function definitions should use double indents for subsequent lines.
  • 5. Parenthesis and Brackets End parenthesis and brackets should be on their own lines. End parenthesis and brackets should either be aligned to the first non-whitespace character of the last line or with the first non-whitespace character of the construct itself.
  • 6. Tabs or Spaces Python 2.x code should always use spaces. Python 3.x code can use spaces or tabs. ◦ To that end, make sure that you are consistent with your tabs and spaces! General recommendation is to use spaces.
  • 7. Line Length <79 characters for regular code. <72 character for comments and documentations.
  • 8. Source File Encoding UTF-8 ASCII for Python 2.x Latin-1 UTF-8 for Python 3.x
  • 9. Naming Conventions Don’t use I’s, O’s, and l’s as single-character variables: ◦ I’s and l’s are almost indistinguishable. ◦ O’s and 0’s are also confusing. Modules should be all lowercase. Underscores recommended only if it makes the name more readable. Class names should be in PascalCase. Function names and instance variables should be lowercase with underscores as necessary. Constants should be ALL_CAPITAL_WITH_UNDERSCORES.
  • 10. Recommendations Code should be written in a way that isn’t a disadvantage of other implementations of Python. When dealing with Boolean operations, use: ◦ “if/for/while var1 is not None:” ◦ But not: “if/for/while not var1 is None:” Empty sequences return a false, use this fact! ◦ Rather than “if len(seq)” ◦ Use “if seq” Don’t compare Boolean values using ==. Try to avoid the use of magic numbers.
  • 11. TL;DR Version Go to this site for information about PEP8: http://legacy.python.org/dev/peps/pep-0008/ Go to this site to check your code: http://pep8online.com/
  • 12. Thanks to: Sean O'Sullivan Professor Moorthy Professor Goldschmidt RCOS