Write Pythonic Code Like a Seasoned Developer Transcripts
Chapter: Modules and Packages
Lecture: Introduction to packaging and module idioms
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
Python is often referred to as a programming language and ecosystem with batteries included, and on one level
0:07
that means it has a really rich standard library. Things like the JSON module that's built-in and so on. It also means looking at the larger ecosystem
0:15
all the 80 000 packages on PyPi, things like that, so in this section we are going to focus on the Python idioms around packages, modules,
0:24
importing them, creating them, those kinds of things. I want to give you just a little bit inspiration before we get to the technical details
0:31
so if I come over here and run Python 3, and I go type in "import", I could say "import json" things like that,
0:38
and then I could say "json.dumps" given a dictionary and so on, right, "json.dumps", here a is 1 and boom, we have JSON,
0:47
but we could also import all sorts of things, we could go to PyPi install some packages and import them
0:53
for example I could "import requests", because I've installed that somewhere, to capture this idea of how amazing packages are,
1:00
we have this concept of "import antigravity", so what happens if I import antigravity? Well something pretty awesome,
1:06
it pulls up this xkcd about why Python is awesome because you can import anything so here I'll just read it to you really quick,
1:14
so we have this guy up here he is totally flying and his friend says, "Dude, how are you flying?"
1:19
"Python, I just learned it last night everything is so simple, hello world is just print "hello world!""
1:24
"I don't know man, dynamic typing? White space?", "Come on, join us, programming is fun again, it's a whole new world up here"
1:31
"But how are you flying?" "I just typed import antigravity", "That's it?" "Well I also sampled everything in the medicine cabinet for comparison,
1:37
but I think it's the Python". This is the feeling you should have as you think about packages and modules and all the stuff that you can do,
1:45
let's talk about the idioms about consuming all these amazing packages.