Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.
Join us and get access to thousands of tutorials and a community of expert Pythonistas.
This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.
Python Modules and Packages: An Introduction (Summary)
00:00 Hey, congratulations! You completed the course. This video is going to be not only a conclusion, but a review of everything that you’ve covered throughout this course.
00:11 It started with an intro and course overview, and then you dove right into writing your own module and importing it.
00:22
The next video let you explore the module search path. Where will your computer look for the modules you’re importing? The import statement was next, and all the different forms that it can take.
00:39
The next video explored namespaces a little deeper by talking about the dir() function and how you can use it to look up the local symbol table.
00:53
After that, you got to practice executing a module as a script, and you learned about the attribute __name__. Then you learned if you import a module a second time, it doesn’t reload the contents inside of it, so you’d have to quit the interpreter and restart it, but you also saw that there is a tool in the importlib module that you can import called reload(). As a project grows, it starts to make sense to look at organizing multiple modules into a package, in that sort of directory structure.
01:32
Then you learned about the __init__.py file that can help you with package initialization.
01:41
The next video was all about wildcard importing and the ways that you can set up your module or packages to set up your user for success if a user is going to use the wildcard (*) when they’re importing.
01:55 As the project may grow and the amount of modules that you have increases, it may make sense to break up the package into subpackages, and how that affects your namespaces. And finally, there was this conclusion and course review.
02:09 I want to thank you for watching this course. Make sure that you take time to practice with what you’ve learned.
Alain Rouleau on July 16, 2020
Already knew a fair amount when it came to creating and working with modules. But now I know so much more, thanks! Definitely going to use what I just learned.
Knowing how to work with packages, modules and creating your own hierarchy is kind of the missing link when it comes to Python, if you ask me. Usually that whole subject is not taught or explained very well. But you made it so simple.
Dennis Smith on Dec. 7, 2020
I have referred back to the article version of this course countless times but these videos worked well to give me a deeper understanding and solidify the knowledge. Well done Chris!
Alex Duzsardi on Jan. 1, 2021
Thank you for this course , it clarified a few things for me.
Krauss on March 2, 2021
Hey Chris, thanks for the great video course. It indeed helped me understanding and filling up some knowledge gaps. One question remains though, is there a way to get the import command to append the newly created modulo’s path dinamically? I’ve tried using the __init__.py file to do the append command but id doesn’t work.
qmark42 on April 19, 2021
Thank you Chris. This course has answered several questions I have had for quite a while. Such things as what does __init__ mean and is it special, have been answered along with some dot notation questions. I will have to review the manuscript as my memory is not so great at times but now I know where to look. Again, Thank you.
nestor on April 23, 2021
I’m preparing myself to get a Python skill to develop one Real Time measurement application using Raspberry Pi 3B, AC and DC energie sensor, this App must have connectivity options for Wi-Fi and Bluetooth and show the measurements in the GUI for mobile or a computer, so, whats Python’s tools do you recomend me to to know and review for this project if I need to do......Real Time, GUI, connectivity protocols Wi-Fi & BLE…?.......I have previus experience programming but in LabVIEW......nothing to do with Python. Thanks for your recomendation.
Carlos on Aug. 1, 2022
Thanks Chris! Comprehensive tutorial. Just a comment related to bpython dunder name, at least 0.20.1 on top of Python 3.8.13, Linux: running the script it is console instead of main
Tyrone on Oct. 8, 2022
Thanks for this great course Chris! I learnt heaps and you made working with made working with modules and packages much clearer and now it seems so easy. Love your easy paced style, clear language and the way you lift the mist in such a matter of fact way. Well done!!.
colmedob on Jan. 14, 2023
Great course, Chris. As my project grew, I needed a way to test functions independently of the main code, and this course gave me the solution.
Become a Member to join the conversation.
Patricio Urrutia on July 5, 2020
Hi Chris, thanks for the course. It was very helpful!
I have a doubt, things like, for example, pandas are modules then? I had imagined that Series and DataFrames were in different modules of the “package” pandas, but it seems, due the way we import it, it is a module.
Or it is a way to accomplish this? (having all the modules and submodules inside the “pkg namespace). Maybe through the init.py file?
Thanks!