Python 04: PEP8 Coding

John Hammond · Intermediate ·🔐 Cybersecurity ·10y ago

Key Takeaways

This video covers PEP8 coding standards in Python, including tools like Sublime Linter and Pylint to automate the process of ensuring code compliance.

Full Transcript

hey what's going on everybody my name is John Hammond and welcome back to another YouTube video tutorial we're still looking at python uh we made a cool little thing here that actually doesn't do a whole lot but it's going over the basics conceptual stuff with input and output and variables and now we're going to move on this time around since we're starting to get into more actual cool and important and things programs that actually do stuff we're going to have to make sure our code is good we have to make sure our code is compliant with python standards and things like that so in Python there's this actual thing like that's called pep 8 it's the uh it's a standard and kind of a visual style guide that python has set out to make sure the python code that you write is pretty smart and I don't know similar to everything else that other people write so it discusses things about indentation discusses uh arguments uh how much how much spacing you should have between uh code how you should comment things and display variables etc etc I recommend you totally read through this but there is something that can kind of help our code be this way um so I'm going to actually run through a little presentation that was put together by Audrey Roy seems like a really awesome individual uh she was doing a bunch of cool stuff with python and this thing is on the Internet is a python tricks you can't live without and it's really about code readability style comments Etc and how to make your python code awesome clear and understandable um it really gets into self-documenting code um it really gets into making sure that you're documenting things with comments and Doc strings and it gets into the Zen of python 2 python is is something that's not only a programming tool but also a conceptual thing where you have a certain code style and I don't know a way of programming that is supposed to be great so I want to show this off this this module that keeps in mind Python's philosophy as you as you are a software developer and a software engineer so I'm going to fire that up in Idol uh just so it's a python interpreter that looks pretty good if you haven't heard of idol it is the integrated development learning environment I think for python uh if you don't have it installed you can pseudo app get install idle and then you should be able to install it just fine I've already have it installed so I'll fire it up and in inside idle we can import this the syntax that they're using right there just importing a module in Python and it tells us about the Zen of python beautiful is better than ugly explicit is better than implicit etc etc really just this philosophy and mindset that we should have when you're writing python code so to do that we want to be in line with that python pep8 standard pep eight really argues that you should have using four spaces no tabs blank lines etc etc ET so it's good to have all this stuff in the back of your mind but it would be pretty awesome if we had some tools that could make sure our python code does this just tools that automate the process for us like some plugins and Sublime Tex too let's check out and install this Sublime linter is apparently something that can do this for us we can install that package in Sublime Tex I just hit control shift p to get the command pallet up and then Sublime linter after I search for a package it should okay now it's just installed awesome so now in our python code sobl linter looks like it's already uh cranking stuff out for us it really hates all of my spaces so let's convert um looks like I can't find it in the menu as to how to convert our tabs to spaces but we should be able to do it in the command pallet yeah indentation convert to spaces and that works just fine for us um and all of these trailing stuff within parenthesis I shouldn't have because pep eight does not like that it wants to have all everything with inside parentheses sees it wants to have no spaces so okay Sublime lter looks pretty awesome for us and what else is there command line pep 8 Checker oh looks like that's just a tool pep bait we can probably set up and install if I actually look in our terminal it is something we can install from the repositories awesome so now that pep bait is available we can run that on the script that we just ran and we don't have any output or any errors so it looks like we're good pilent looks like it can do pretty similar stuff let's check that out pilent pilent on our variables oh wow this is really cool actually haven't seen this before inv valid constant name I wonder what all that stuff is checking line CES link variable names are well formed according to your colding standard this is really cool I actually haven't seen pilent before so this is definitely something to look into if you are interested in the kind of stuff that looks like it's given out invalid name huh what else is there and then the rest of this goes into important stuff that you can do with python that's pretty awesome um but I really wanted to show off the pep eight standard I really recommend you read through this um but the sublime lint uh package that we just installed looks like it'll be really awesome for us it'll make sure that the code that I write and also the code that you guys write is within the pep eight standard because actually I recorded a lot of these videos uh a while back and the standard that I use I had like really disgusting code BRAC that would represent like I actually commented out code code braces to represent my logic flow and I would end each line in Python with a semicolon which is just hideous no one liked it I got I got a lot of flag for it so I'm trying to do a lot better with this time around so having these tools like pep eight that command line utility and now pilent I want to look more into that and Sublime linter to keep things within the pep eight standard that should be pretty cool um and I hope you guys enjoy it and can actually follow along and use that same same tool with me so all right uh that's really all I want to show off in this tutorial nothing big but keeping track with that pep B standard and making sure the code that we write is within a certain compliant standard thing so yeah thanks for watching guys see you soon

Original Description

If you would like to support me, please like, comment & subscribe, and check me out on Patreon: https://patreon.com/johnhammond010 E-mail: johnhammond010@gmail.com PayPal: http://paypal.me/johnhammond010 GitHub: https://github.com/JohnHammond Site: http://www.johnhammond.org Twitter: https://twitter.com/_johnhammond
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from John Hammond · John Hammond · 26 of 60

1 Code Commentaries? PHP to JavaScript in Bash and PHP!
Code Commentaries? PHP to JavaScript in Bash and PHP!
John Hammond
2 Tutorials? MySQL connection with PHP and Bash!
Tutorials? MySQL connection with PHP and Bash!
John Hammond
3 Variable Naming in Python! Happy Birthday, Linux! Nokia N900!
Variable Naming in Python! Happy Birthday, Linux! Nokia N900!
John Hammond
4 JavaScript Splits The URL!
JavaScript Splits The URL!
John Hammond
5 HTML Tables in Python!
HTML Tables in Python!
John Hammond
6 HTML, Net Shares, GML!
HTML, Net Shares, GML!
John Hammond
7 Python 08 Programming Style and Comments
Python 08 Programming Style and Comments
John Hammond
8 Python 26 Object Oriented Programming
Python 26 Object Oriented Programming
John Hammond
9 75 Python Tutorials, Out Now!
75 Python Tutorials, Out Now!
John Hammond
10 Batch 14 Mathematical Expressions
Batch 14 Mathematical Expressions
John Hammond
11 Batch 85 Array Append
Batch 85 Array Append
John Hammond
12 Batch 86 Array Count
Batch 86 Array Count
John Hammond
13 Batch 87 Array Index
Batch 87 Array Index
John Hammond
14 Batch 88 Array Insert
Batch 88 Array Insert
John Hammond
15 Batch 89 Array Remove
Batch 89 Array Remove
John Hammond
16 Batch 90 Array Reverse
Batch 90 Array Reverse
John Hammond
17 Python [colorama] 00 Installing on Linux
Python [colorama] 00 Installing on Linux
John Hammond
18 Python [colorama] 09 Cursor Position
Python [colorama] 09 Cursor Position
John Hammond
19 Python [hashlib] 02 Algorithms
Python [hashlib] 02 Algorithms
John Hammond
20 Python 00 Installing IDLE on Linux
Python 00 Installing IDLE on Linux
John Hammond
21 Python [pygame] 11 Rectangular Collision Detection
Python [pygame] 11 Rectangular Collision Detection
John Hammond
22 Python [pygame] 12 Platforming Rectangular Collision Resolution
Python [pygame] 12 Platforming Rectangular Collision Resolution
John Hammond
23 Python [XML-RPC] 01 Research
Python [XML-RPC] 01 Research
John Hammond
24 Python [pyenchant] 03 Personal Word Lists
Python [pyenchant] 03 Personal Word Lists
John Hammond
25 FancyURLopener Authentication and User-Agent [urllib] 03
FancyURLopener Authentication and User-Agent [urllib] 03
John Hammond
Python 04: PEP8 Coding
Python 04: PEP8 Coding
John Hammond
27 Python Challenge! 17 COOKIES
Python Challenge! 17 COOKIES
John Hammond
28 Google CTF 2016: Ernst Echidna
Google CTF 2016: Ernst Echidna
John Hammond
29 Google CTF 2016: Spotted Quoll
Google CTF 2016: Spotted Quoll
John Hammond
30 Google CTF 2016: Can you Repo It?
Google CTF 2016: Can you Repo It?
John Hammond
31 Google CTF 2016: No Big Deal
Google CTF 2016: No Big Deal
John Hammond
32 Google CTF 2016: In Recorded Conversation
Google CTF 2016: In Recorded Conversation
John Hammond
33 Homemade CTF Challenge: 01 "Orchestra"
Homemade CTF Challenge: 01 "Orchestra"
John Hammond
34 Homemade CTF Challenge: 02 "Bae's Base"
Homemade CTF Challenge: 02 "Bae's Base"
John Hammond
35 Homemade CTF Challenge: 03 "Web Hunt"
Homemade CTF Challenge: 03 "Web Hunt"
John Hammond
36 Homemade CTF Challenge: 04 "UPX"
Homemade CTF Challenge: 04 "UPX"
John Hammond
37 Homemade CTF Challenge: 05 "The Assumption Song"
Homemade CTF Challenge: 05 "The Assumption Song"
John Hammond
38 Homemade CTF Challenge: 06 "A Brisk Stroll"
Homemade CTF Challenge: 06 "A Brisk Stroll"
John Hammond
39 Homemade CTF Challenge: 06 "I lost my password!"
Homemade CTF Challenge: 06 "I lost my password!"
John Hammond
40 web25 :: Mr. Robot : EKOPARTY CTF 2016
web25 :: Mr. Robot : EKOPARTY CTF 2016
John Hammond
41 web50 : RFC 7230 :: EKOPARTY CTF 2016
web50 : RFC 7230 :: EKOPARTY CTF 2016
John Hammond
42 misc50 : Hidden inside EKO :: EKOPARTY CTF 2016
misc50 : Hidden inside EKO :: EKOPARTY CTF 2016
John Hammond
43 Hack The Vote 2016 CTF: Sander's Fan Club [web100]
Hack The Vote 2016 CTF: Sander's Fan Club [web100]
John Hammond
44 Hack The Vote 2016 CTF Warpspeed [forensics150]
Hack The Vote 2016 CTF Warpspeed [forensics150]
John Hammond
45 Juniors CTF 2016 :: Black Suprematic Square
Juniors CTF 2016 :: Black Suprematic Square
John Hammond
46 Juniors CTF 2016 :: Six Strange Tales
Juniors CTF 2016 :: Six Strange Tales
John Hammond
47 Juniors CTF 2016 :: Lost Code
Juniors CTF 2016 :: Lost Code
John Hammond
48 Juniors CTF 2016 :: Here Goes!
Juniors CTF 2016 :: Here Goes!
John Hammond
49 Juniors CTF 2016 :: Southern Cross
Juniors CTF 2016 :: Southern Cross
John Hammond
50 Juniors CTF 2016 :: Clone Attack
Juniors CTF 2016 :: Clone Attack
John Hammond
51 Juniors CTF 2016 :: Dirty Repo
Juniors CTF 2016 :: Dirty Repo
John Hammond
52 Juniors CTF 2016 :: Hackers Blog
Juniors CTF 2016 :: Hackers Blog
John Hammond
53 Juniors CTF 2016 :: Voting!!!
Juniors CTF 2016 :: Voting!!!
John Hammond
54 Juniors CTF 2016 :: The Good, The Bad and The Junkman
Juniors CTF 2016 :: The Good, The Bad and The Junkman
John Hammond
55 Juniors CTF 2016 :: Stop Thief!
Juniors CTF 2016 :: Stop Thief!
John Hammond
56 Juniors CTF 2016 :: ROFL
Juniors CTF 2016 :: ROFL
John Hammond
57 Juniors CTF 2016 :: Restriced Area
Juniors CTF 2016 :: Restriced Area
John Hammond
58 Juniors CTF 2016 :: Oh SSH!
Juniors CTF 2016 :: Oh SSH!
John Hammond
59 HackCon CTF 2017 TRIVIA and BONUS Challenges
HackCon CTF 2017 TRIVIA and BONUS Challenges
John Hammond
60 HackCon CTF 2017 "Bacche" Challenges
HackCon CTF 2017 "Bacche" Challenges
John Hammond

This video teaches how to write compliant Python code using PEP8 standards and tools like Sublime Linter and Pylint. It covers the importance of code readability and style in software development.

Key Takeaways
  1. Install Sublime Linter
  2. Configure Sublime Linter to check for PEP8 compliance
  3. Run Pylint on Python code to check for errors
  4. Use IDLE to write and test Python code
  5. Read and understand the Zen of Python
💡 Using tools like Sublime Linter and Pylint can help automate the process of ensuring code compliance with PEP8 standards.

Related Reads

📰
PicoCTF: Format String 0 — The Intended Way vs. The Fast Way
Learn to exploit format string vulnerabilities in binary exploitation through PicoCTF challenges
Medium · Cybersecurity
📰
VulnNet (THM) Tryhackme Walkthrough
Exploit misconfigurations in VulnNet Entertainment to learn cybersecurity skills
Medium · Cybersecurity
📰
WAF Bypass Methodology for XSS
Learn a methodology to bypass Web Application Firewalls (WAFs) for Cross-Site Scripting (XSS) vulnerabilities, understanding that filters don't remove vulnerabilities
Medium · Cybersecurity
📰
CYBERDUDEBIVASH® Ecosystem: The AI Security, Threat Intelligence, and Identity Defense Stack —…
Explore the CYBERDUDEBIVASH ecosystem for AI security, threat intelligence, and identity defense with its various platforms and tools
Medium · Cybersecurity
Up next
Google Did The Impossible
Boot dev
Watch →