Modules and packages
Modules and packages
Modules, the big picture: Why Modules?; Python program architecture; How imports work; Byte code files; The module search path. Large programs are divided into multiple files, which are linked together at runtime by imports.
From module source code file to module object: When that module is imported. Set PYTHONPATH environment variable: if the file is not in the current working directory. What is a namespace and what contains?: self-contained package of variables, known as the attributes of the namespace object.
Module coding basics: Module creation; Module usage; Module namespaces; Reloading modules.
How do you make a module?: write a text file containing python statements, every source code file is automatically a module. How is the reload function related to imports?: force a module to be imported again; pick up new version of a module's during development.
Module packages: Package import; Why use package imports?; Package relative imports; Namespace package.
Purpouse of an init.py file in a module: declare and initialize a regular module package, runs its code the first time tou import through a directory in a process.
Advance topics: Module design concepts; Data hiding in modules; Enabling future language features; Mixed usage modes; Changing the module search path; The as extension for import and from; importing modules by name string; Module gotchas.
What does it mean when a module's name variable is the string 'main'?: means the file is being executed as a top-level script instead of being imported from another file in the program; the file is being used as a program, not a library.
Última actualización
¿Te fue útil?