Category: 9. Modules & Packages
-
Python __name__
Summary: in this tutorial, you’ll learn about the Python __name__ variable and how to use it effectively in modules. What’s Python __name__? If you have gone through Python code, you’ve likely seen the __name__ variable like the following: And you might wonder what the __name__ variable is. Since the __name__ variable has double underscores at both sides, it’s called dunder name. The dunder stands for double underscores…
-
Python Module Search Path
Summary: in this tutorial, you’ll learn how the module search path works in Python when you import a module into a program. Introduction to Python module search path When you import a module in a program: Python will search for the module.py file from the following sources: Python stores the resulting search path in the sys.path variable that comes from the sys module.…
-
Python Modules
Summary: in this tutorial, you’ll learn about Python modules, how to import objects from a module, and how to develop your modules. Introduction to Python modules A module is a piece of software that has a specific functionality. A Python module is a file that contains Python code. For example, when building a shopping cart…