#100DaysOfCode in Python Transcripts
Chapter: Days 34-36: Refactoring / Pythonic code
Lecture: Refactoring / code quality resources
0:00 In this video I'll provide you some extra resources
0:03 to read up about refactoring
0:05 and how to make your code more Pythonic.
0:08 Read about the topic of refactoring,
0:10 we have a whole dedicated post
0:12 on the importance of refactoring code.
0:15 Errors should not pass silently, as we've seen.
0:19 So a lot of this we've discussed in this notebook,
0:22 but it shows you some more examples.
0:24 This is an important one, there's some Python mistakes
0:28 the beginner is likely to make.
0:30 And we listed them here
0:31 so you can know about them in advance.
0:34 There's string formatting we discussed
0:38 and Julian had a very nice article here.
0:41 From going from the terribly un-Pythonic method
0:44 to the nicer way.
0:45 And I think he come to the same conculsion
0:47 that you really want to use f-strings if you can,
0:50 if you're on 3.6.
0:52 There's an awesome talk about beautiful idiomatic Python,
0:55 by Raymond Hettinger.
0:57 I learned a lot from this talk,
0:59 there's a lot of good tips and tricks in it.
1:01 And we've made a summary in this blog post.
1:04 And when we talk about modules, and splitting your code,
1:08 it becomes important to know about packaging your code.
1:11 So here we have a post about how to do that
1:14 on a practical project, like her Karma Bot.
1:17 And it's not that hard, I mean basically
1:19 you have to make an init.py file
1:22 and know how to import your stuff.
1:24 That's important.
1:25 The imports mights be confusing,
1:27 but with this article it should become clearer.
1:30 So when we're talking about splitting code
1:32 and making it maintainable, know how to work with modules
1:35 and packaging is important.
1:37 And generic code quality resources, I have two.
1:41 First of all Martin Fowler's Refactoring Book,
1:44 and yes, the examples are in Java, not Python.
1:47 But it's about the general principles.
1:50 And this book really teaches you how to write better code.
1:53 It shows you very practical examples
1:56 how you can refactor bad code
1:58 into much more maintainable code.
2:00 It's a great read.
2:02 And of course, Uncle Bob's Clean Code, a classic.
2:06 And also shows you a lot of ways
2:08 to write professional quality code.