Python Jumpstart by Building 10 Apps Transcripts
Chapter: App 4: Journal app and file I/O
Lecture: Core concept: Importing modules and packages
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
The concept of importing modules and packages is very central to Python and it's what really provides the ability to
0:10
have Python be this so called "batteries included" language where if there is some sort of feature that you need,
0:16
there is a few lines of code you write and boom, you have it. Typically, it've to import some amazing package that's going to solve your problem.
0:24
Now we saw there is three ways that we can import, there is actually more than that but I think this is enough to get us started.
0:31
We can say import, name of the package or module, and that both allows and requires us to maintain the namespace down below you can see os.path.exists,
0:42
or we can import individual entities, functions, variables, classes and so on out of the modules like from os import path, that's ok,
0:52
it's not amazingly good, but it's not bad, and that lets us write style too, we could take the lazy way and import everything out of the os
0:59
regardless whether we are going to use it, that's not such a good idea you kind of get into name conflicts
1:05
and it's not very obvious what you are actually getting from that module and where are you using it below,
1:10
that would still let you write style to code below.