![]() Modules which are designed to be imported by other code won't execute any code, but only expose its top-level names as attributes to the imported object. Python files which are used to run as a stand-alone Python app (top-level files) are usually designed to run as scripts and importing them would actually run the commands in the script. Although, not every Python file is designed to be imported as a module. There's really not much philosophy in creating a Python module since files with a. In this article we start from the core basics of module creation and importing, to more advanced module usage cases, to packaging and submitting your modules to an "official" Python software repository, structured respectively into three parts: Creating a Module, Using a Module, and Submitting a Package to PyPI. You can also understand them as packages of names, which when imported become attributes of the imported module object. They're self-contained because you can only access a module's attributes after importing it. So what exactly is a module? Modules are units that store code and data, provide code-reuse to Python projects, and are also useful in partitioning the system's namespaces in self-contained packages. If you're at least a little familiar with Python, you've probably not only used ready modules, but also created a few yourself. Modules are the highest level organizational unit in Python.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |