Mastering PyCharm Transcripts
Chapter: The Editor
Lecture: Formatting and code cleanup

Login or purchase this course to watch this video and the rest of the course contents.
0:01 In Python, it's great that we have pep 8,
0:04 it tells us how to format our code, how to name our variables and so on.
0:07 However, we don't always follow it
0:09 or more writing code, reorganizing code,
0:12 sometimes we get it into a place where it doesn't quite line up.
0:15 So if we hover over say this change address thing
0:18 there's actually a few problems.
0:20 First of all, pep 8 says we expected two blank lines
0:23 from the find user by email function
0:26 so it should have two more lines below;
0:28 and according to our current conventions,
0:30 we really should have something like change (lowercase a) address
0:33 this is very much like Javascript style or Java style of function naming
0:40 both for new email and for change address
0:42 and it's not very Pythonic we should be using snake case after all.
0:46 How do we fix this?
0:48 Well, if we just hit CMD ALT L or CTRL ALT L
0:53 or whatever the hotkey is for reformat code
0:56 as we saw before this can change,
0:58 but on Mac by default is CMD ALT L and I think CTRL alt L on the others
1:02 it will reformat this and fix the pep 8 violations
1:06 so you notice that it actually went and it said
1:09 okay we'll put those two lines there for you
1:11 and if there was like other spaces or other minor things
1:13 they will all be automatically fixed.
1:15 But a change address— well, if we're going to change address
1:18 that actually might break other code and other modules
1:22 or heck if this is a package that somebody uploads to PyPi,
1:27 and then someone else downloads it,
1:29 that could have like far ranging problems or knock on effect
1:32 so it's not going to fix that automatically,
1:34 but the refactoring would let us fix it at least within our project right away,
1:38 but it will just give us a warning no autofix.