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