Write Pythonic Code Like a Seasoned Developer Transcripts
Chapter: Welcome to the course
Lecture: Topics covered
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
What areas are we going to cover in this class? Well, we are going to start with the foundations and this concept called PEP 8.
0:07
So, PEP 8 is a standardized document that talks about the way code should be formatted, and even some of the Pythonic ideas and Pythonic code examples.
0:17
However, we are going to go way beyond PEP 8 in this course, and so we'll probably spend 15 minutes talking about PEP 8
0:23
and then we'll move onto other foundational items. Then we are going to focus on dictionaries, dictionaries play a super important role in Python,
0:31
they are basically the backing store for classes, they are used for data exchange all over the place,
0:38
and there are a lot of interesting use cases and ways in which dictionaries are used in a language.
0:44
We are going to talk about a lot of interesting aspects and optimal ways to use and leverage dictionaries. Next up are working with collections,
0:52
things called list comprehensions and generator expressions. And we'll see that Python has a lot of interesting flexibility
0:59
around working with sequences, and we'll see the best way to do this here. Next, functions and methods.
1:07
This will include the use of things like lambda expressions for small inline methods,
1:12
as well as returning multiple values from methods and that sort of things. There is a lot to look at to write Pythonic functions.
1:18
One of the great powers of Python is the ability to import or pip install a whole variety of packages,
1:26
there is even a great xkcd cartoon about importing packages in Python, and we'll see that there are a lot of interesting Pythonic conventions
1:34
around working with packages and modules. Next up, we are going to look at classes and objects.
1:41
Object oriented programming in Python is a key cornerstone concept, even though it may play a slightly less important role
1:48
than languages like Java and C#, still, classes are really important and there is a lot of idiomatic conventions around working with classes,
1:56
we'll focus on that in this section. Python has a lot of powerful ways of working with loops,
2:02
one of the first giveaways if somebody is brand new to Python is they are not using loops correctly,
2:08
so we'll talk about when and how you should use loops and we'll even talk about the controversial else clause for "for...in" and "while" loops.
2:15
Next, we'll talk about tuples. Tuples are smallish, read-only collections that let you package up related possibly heterogeneous data
2:24
and pass it around, If we go into a basic database queries and the built in DB API you'll see that the rows come back as tuples.
2:32
Some of the powerful techniques we'll learn about loops involve tuples and we'll see that tuples in general play a really important role,
2:38
and there is some powerful and useful conventions around working with tuples in Python. Finally, we are going to look beyond the standard library,
2:46
with something I am calling Python for Humans; one of the great powers of Python is the ability to go out to PyPi
2:52
and grab one of the over 80 000 packages, install them using pip or something like this and add amazing powers to your application.
3:01
People who are new to Python often skip this step and they look at something they have to do and are just like
3:08
OK I think "I can implement it in these 20 lines of code". It's very likely that there is already a package out there that you can use to do this,
3:17
so we are going to study two packages one for HTTP and one for database access to really bring home this point of look to PyPi
3:25
and look to open source first before you start writing your own algorithms. Of course, over time, we may add more topics than what are described here,
3:33
I am sure as more and more people take this class they will say, "Hey Michael, did you think about having this",
3:39
or "I also consider this little bit to be idiomatic." Now I don't want to just grab every single detail that I can find,
3:45
that is possibly Pythonic code and cram it in here, I want to cover the stuff that's most important and not waste your time,
3:51
but of course, I am sure we'll hear about some new ones that are great and those may be folded in over time.