際際滷

際際滷Share a Scribd company logo
By James Braunsberg
What are Modules?
 Modules are files containing Python definitions
and statements (ex. name.py)
 A modules definitions can be imported into
other modules by using import name
 The modules name is available as a global
variable value
 To access a modules functions, type
name.function()
More on Modules
 Modules can contain executable statements along with
function definitions
 Each module has its own private symbol table used as
the global symbol table by all functions in the module
 Modules can import other modules
 Each module is imported once per interpreter session
 reload(name)
 Can import names from a module into the importing
modules symbol table
 from mod import m1, m2 (or *)
 m1()
Executing Modules
 python name.py <arguments>
 Runs code as if it was imported
 Setting _name_ == _main_ the file can be used as
a script and an importable module
The Module Search Path
 The interpreter searches for a file named
name.py
 Current directory given by variable sys.path
 List of directories specified by PYTHONPATH
 Default path (in UNIX - .:/usr/local/lib/python)
 Script being run should not have the same name
as a standard module or an error will occur
when the module is imported
Compiled Python Files
 If files mod.pyc and mod.py are in the same directory,
there is a byte-compiled version of the module mod
 The modification time of the version of mod.py used
to create mod.pyc is stored in mod.pyc
 Normally, the user does not need to do anything to
create the .pyc file
 A compiled .py file is written to the .pyc
 No error for failed attempt, .pyc is recognized as invalid
 Contents of the .pyc can be shared by different
machines
Some Tips
 -O flag generates optimized code and stores it in .pyo files
 Only removes assert statements
 .pyc files are ignored and .py files are compiled to optimized
bytecode
 Passing two OO flags
 Can result in malfunctioning programs
 _doc_ strings are removed
 Same speed when read from .pyc, .pyo, or .py files, .pyo and .pyc
files are loaded faster
 Startup time of a script can be reduced by moving its code to a
module and importing the module
 Can have a .pyc or .pyo file without having a .py file for the same
module
 Module compileall creates .pyc or .pyo files for all modules in a
directory
Standard Modules
 Python comes with a library of standard modules described
in the Python Library Reference
 Some are built into interpreter
 >>> import sys
>>> sys.s1
>>> 
>>> sys.s1 = c> 
c> print Hello
Hello
c>
 sys.path determines the interpreterss search path for
modules, with the default path taken from PYTHONPATH
 Can be modified with append() (ex.
Sys.path.append(SOMEPATH)
The dir() Function
 Used to find the names a module defines and returns
a sorted list of strings
 >>> import mod
>>> dir(mod)
[_name_, m1, m2]
 Without arguments, it lists the names currently
defined (variables, modules, functions, etc)
 Does not list names of built-in functions and
variables
 Use _bulltin_to view all built-in functions and variables
Packages
 dotted module names (ex. a.b)
 Submodule b in package a
 Saves authors of multi-module packages from worrying
about each others module names
 Python searches through sys.path directories for the
package subdirectory
 Users of the package can import individual modules from
the package
 Ways to import submodules
 import sound.effects.echo
 from sound.effects import echo
 Submodules must be referenced by full name
 An ImportError exception is raised when the package
cannot be found
Importing * From a Package
 * does not import all submodules from a package
 Ensures that the package has been imported,
only importing the names of the submodules
defined in the package
 import sound.effects.echo
import sound.effects.surround
from sound.effects import *
Intra-package References
 Submodules can refer to each other
 Surround might use echo module
 import echo also loads surround module
 import statement first looks in the containing package
before looking in the standard module search path
 Absolute imports refer to submodules of sibling
packages
 sound.filters.vocoder uses echo module
from sound.effects import echo
 Can write explicit relative imports
 from . import echo
 from .. import formats
 from ..filters import equalizer
Packages in Multiple
Directories
 _path_ is a list containing the name of the
directory holding the packages _init_.py
 Changing this variable can affect futute searches
for modules and subpackages in the package
 Can be used to extend the set of modules in a
package
 Not often needed
Sources
 http://docs.python.org/tutorial/modules.html

More Related Content

Similar to mod.ppt mod.ppt mod.ppt mod.ppt mod.pp d (20)

Functions_in_Python.pdf text CBSE class 12
Functions_in_Python.pdf text CBSE class 12Functions_in_Python.pdf text CBSE class 12
Functions_in_Python.pdf text CBSE class 12
JAYASURYANSHUPEDDAPA
Using Python Libraries.pdf
Using Python Libraries.pdfUsing Python Libraries.pdf
Using Python Libraries.pdf
SoumyadityaDey
Python import mechanism
Python import mechanismPython import mechanism
Python import mechanism
Yuki Nishiwaki
library-basics python.pptx for education
library-basics python.pptx for educationlibrary-basics python.pptx for education
library-basics python.pptx for education
ShubhamShinde648276
Modules in Python Programming
Modules in Python ProgrammingModules in Python Programming
Modules in Python Programming
sambitmandal
Python libraries
Python librariesPython libraries
Python libraries
Prof. Dr. K. Adisesha
packages.pptx
packages.pptxpackages.pptx
packages.pptx
SHAIKIRFAN715544
Pythonpresent
PythonpresentPythonpresent
Pythonpresent
Chui-Wen Chiu
Chapter 03 python libraries
Chapter 03 python librariesChapter 03 python libraries
Chapter 03 python libraries
Praveen M Jigajinni
7-_Modules__Packagesyyyyyyyyyyyyyyyyyyyyyyyyyyyyy.pptx
7-_Modules__Packagesyyyyyyyyyyyyyyyyyyyyyyyyyyyyy.pptx7-_Modules__Packagesyyyyyyyyyyyyyyyyyyyyyyyyyyyyy.pptx
7-_Modules__Packagesyyyyyyyyyyyyyyyyyyyyyyyyyyyyy.pptx
RoshanJoshuaR
Python modules
Python   modulesPython   modules
Python modules
Learnbay Datascience
Using python libraries.pptx , easy ppt to study class 12
Using python libraries.pptx , easy ppt to study class 12Using python libraries.pptx , easy ppt to study class 12
Using python libraries.pptx , easy ppt to study class 12
anikedheikhamsingh
Python for Beginners
Python  for BeginnersPython  for Beginners
Python for Beginners
DrRShaliniVISTAS
Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)
sroo galal
Object oriented programming design and implementation
Object oriented programming design and implementationObject oriented programming design and implementation
Object oriented programming design and implementation
afsheenfaiq2
Object oriented programming design and implementation
Object oriented programming design and implementationObject oriented programming design and implementation
Object oriented programming design and implementation
afsheenfaiq2
Functions and Modules.pptx
Functions and Modules.pptxFunctions and Modules.pptx
Functions and Modules.pptx
Ashwini Raut
Python. libraries. modules. and. all.pdf
Python. libraries. modules. and. all.pdfPython. libraries. modules. and. all.pdf
Python. libraries. modules. and. all.pdf
prasenjitghosh1998
Python Tutorial Part 2
Python Tutorial Part 2Python Tutorial Part 2
Python Tutorial Part 2
Haitham El-Ghareeb
Python Programming - Functions and Modules
Python Programming - Functions and ModulesPython Programming - Functions and Modules
Python Programming - Functions and Modules
Omid AmirGhiasvand
Functions_in_Python.pdf text CBSE class 12
Functions_in_Python.pdf text CBSE class 12Functions_in_Python.pdf text CBSE class 12
Functions_in_Python.pdf text CBSE class 12
JAYASURYANSHUPEDDAPA
Using Python Libraries.pdf
Using Python Libraries.pdfUsing Python Libraries.pdf
Using Python Libraries.pdf
SoumyadityaDey
Python import mechanism
Python import mechanismPython import mechanism
Python import mechanism
Yuki Nishiwaki
library-basics python.pptx for education
library-basics python.pptx for educationlibrary-basics python.pptx for education
library-basics python.pptx for education
ShubhamShinde648276
Modules in Python Programming
Modules in Python ProgrammingModules in Python Programming
Modules in Python Programming
sambitmandal
7-_Modules__Packagesyyyyyyyyyyyyyyyyyyyyyyyyyyyyy.pptx
7-_Modules__Packagesyyyyyyyyyyyyyyyyyyyyyyyyyyyyy.pptx7-_Modules__Packagesyyyyyyyyyyyyyyyyyyyyyyyyyyyyy.pptx
7-_Modules__Packagesyyyyyyyyyyyyyyyyyyyyyyyyyyyyy.pptx
RoshanJoshuaR
Using python libraries.pptx , easy ppt to study class 12
Using python libraries.pptx , easy ppt to study class 12Using python libraries.pptx , easy ppt to study class 12
Using python libraries.pptx , easy ppt to study class 12
anikedheikhamsingh
Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)
sroo galal
Object oriented programming design and implementation
Object oriented programming design and implementationObject oriented programming design and implementation
Object oriented programming design and implementation
afsheenfaiq2
Object oriented programming design and implementation
Object oriented programming design and implementationObject oriented programming design and implementation
Object oriented programming design and implementation
afsheenfaiq2
Functions and Modules.pptx
Functions and Modules.pptxFunctions and Modules.pptx
Functions and Modules.pptx
Ashwini Raut
Python. libraries. modules. and. all.pdf
Python. libraries. modules. and. all.pdfPython. libraries. modules. and. all.pdf
Python. libraries. modules. and. all.pdf
prasenjitghosh1998
Python Programming - Functions and Modules
Python Programming - Functions and ModulesPython Programming - Functions and Modules
Python Programming - Functions and Modules
Omid AmirGhiasvand

Recently uploaded (20)

Different Joinery.pdf.....................
Different Joinery.pdf.....................Different Joinery.pdf.....................
Different Joinery.pdf.....................
martinezmaryjanelle
How often should I change my Tesla brakes
How often should I change my Tesla brakesHow often should I change my Tesla brakes
How often should I change my Tesla brakes
Motronix
AllThirteenPrereadingActivityBackgroundInfoVASOLsCommonCore-1.pdf
AllThirteenPrereadingActivityBackgroundInfoVASOLsCommonCore-1.pdfAllThirteenPrereadingActivityBackgroundInfoVASOLsCommonCore-1.pdf
AllThirteenPrereadingActivityBackgroundInfoVASOLsCommonCore-1.pdf
ShiquettaHughes
Quality _Weekly BRM 05.08.24 TO 11.08.24 (W-19) - Copy (2).pptx
Quality _Weekly BRM  05.08.24 TO 11.08.24 (W-19) - Copy (2).pptxQuality _Weekly BRM  05.08.24 TO 11.08.24 (W-19) - Copy (2).pptx
Quality _Weekly BRM 05.08.24 TO 11.08.24 (W-19) - Copy (2).pptx
ssuser26e9871
Wizard's Portfolio by 際際滷sgo.pasdsaptx
Wizard's Portfolio by 際際滷sgo.pasdsaptxWizard's Portfolio by 際際滷sgo.pasdsaptx
Wizard's Portfolio by 際際滷sgo.pasdsaptx
CasadaInformtica
1-OLEOCHEMICAL and FATTY ALCOHOL OVERVIEW.pptx
1-OLEOCHEMICAL and FATTY ALCOHOL OVERVIEW.pptx1-OLEOCHEMICAL and FATTY ALCOHOL OVERVIEW.pptx
1-OLEOCHEMICAL and FATTY ALCOHOL OVERVIEW.pptx
HieuPham72153
AI Monday - Recognition (1) By Saoirse MacLaughlin
AI Monday - Recognition (1) By Saoirse MacLaughlinAI Monday - Recognition (1) By Saoirse MacLaughlin
AI Monday - Recognition (1) By Saoirse MacLaughlin
office377537
The state of infrastructure in Southern California
The state of infrastructure in Southern CaliforniaThe state of infrastructure in Southern California
The state of infrastructure in Southern California
Bisnar Chase Personal Injury Attorneys
John Deere 540G, 640G, 740G Skidder & 548G, 648G, 748G Grapple Skidder Repair...
John Deere 540G, 640G, 740G Skidder & 548G, 648G, 748G Grapple Skidder Repair...John Deere 540G, 640G, 740G Skidder & 548G, 648G, 748G Grapple Skidder Repair...
John Deere 540G, 640G, 740G Skidder & 548G, 648G, 748G Grapple Skidder Repair...
Service Repair Manual
BMW AC Blowing Hot Air A Guide for Owners
BMW AC Blowing Hot Air A Guide for OwnersBMW AC Blowing Hot Air A Guide for Owners
BMW AC Blowing Hot Air A Guide for Owners
Terry Sayther Automotive
The Udenzes.pptxggggggggggggggggggggggggggggggg
The Udenzes.pptxgggggggggggggggggggggggggggggggThe Udenzes.pptxggggggggggggggggggggggggggggggg
The Udenzes.pptxggggggggggggggggggggggggggggggg
tobennaudenze
Troubleshooting Volkswagen AC Issues Professional Solutions for Optimal Cooli...
Troubleshooting Volkswagen AC Issues Professional Solutions for Optimal Cooli...Troubleshooting Volkswagen AC Issues Professional Solutions for Optimal Cooli...
Troubleshooting Volkswagen AC Issues Professional Solutions for Optimal Cooli...
Medway Imports
What is the engine problem with Mercedes
What is the engine problem with MercedesWhat is the engine problem with Mercedes
What is the engine problem with Mercedes
Das European Autohaus
鴛鰻意粥喝永姻看堰顎艶姻岳温喝珂温稼顎温鉛喝糸艶喝鉛温喝鞄顎艶姻岳温喝温乙姻看艶界看鉛坦乙庄界温.沿糸韓
鴛鰻意粥喝永姻看堰顎艶姻岳温喝珂温稼顎温鉛喝糸艶喝鉛温喝鞄顎艶姻岳温喝温乙姻看艶界看鉛坦乙庄界温.沿糸韓鴛鰻意粥喝永姻看堰顎艶姻岳温喝珂温稼顎温鉛喝糸艶喝鉛温喝鞄顎艶姻岳温喝温乙姻看艶界看鉛坦乙庄界温.沿糸韓
鴛鰻意粥喝永姻看堰顎艶姻岳温喝珂温稼顎温鉛喝糸艶喝鉛温喝鞄顎艶姻岳温喝温乙姻看艶界看鉛坦乙庄界温.沿糸韓
JuanPabloAcosta24
Future Automotive Manufacturing Process & Materials.pdf
Future Automotive Manufacturing Process & Materials.pdfFuture Automotive Manufacturing Process & Materials.pdf
Future Automotive Manufacturing Process & Materials.pdf
aabirforwork
Project about Electric vehicle report In
Project about Electric vehicle report InProject about Electric vehicle report In
Project about Electric vehicle report In
VMathewsMass
Why does my Mini Cooper car ride so rough
Why does my Mini Cooper car ride so roughWhy does my Mini Cooper car ride so rough
Why does my Mini Cooper car ride so rough
European Auto Tech
How to Troubleshoot and Fix Air Conditioning Issues in Your Land Rover
How to Troubleshoot and Fix Air Conditioning Issues in Your Land RoverHow to Troubleshoot and Fix Air Conditioning Issues in Your Land Rover
How to Troubleshoot and Fix Air Conditioning Issues in Your Land Rover
Autowerks
1. Rural sociology meaning.pptxblquschpchdjogsclkhc
1. Rural sociology meaning.pptxblquschpchdjogsclkhc1. Rural sociology meaning.pptxblquschpchdjogsclkhc
1. Rural sociology meaning.pptxblquschpchdjogsclkhc
movieshubs123
UAP Market Development Strategy Brandon, MB
UAP Market Development Strategy  Brandon, MBUAP Market Development Strategy  Brandon, MB
UAP Market Development Strategy Brandon, MB
Arda Ozbek
Different Joinery.pdf.....................
Different Joinery.pdf.....................Different Joinery.pdf.....................
Different Joinery.pdf.....................
martinezmaryjanelle
How often should I change my Tesla brakes
How often should I change my Tesla brakesHow often should I change my Tesla brakes
How often should I change my Tesla brakes
Motronix
AllThirteenPrereadingActivityBackgroundInfoVASOLsCommonCore-1.pdf
AllThirteenPrereadingActivityBackgroundInfoVASOLsCommonCore-1.pdfAllThirteenPrereadingActivityBackgroundInfoVASOLsCommonCore-1.pdf
AllThirteenPrereadingActivityBackgroundInfoVASOLsCommonCore-1.pdf
ShiquettaHughes
Quality _Weekly BRM 05.08.24 TO 11.08.24 (W-19) - Copy (2).pptx
Quality _Weekly BRM  05.08.24 TO 11.08.24 (W-19) - Copy (2).pptxQuality _Weekly BRM  05.08.24 TO 11.08.24 (W-19) - Copy (2).pptx
Quality _Weekly BRM 05.08.24 TO 11.08.24 (W-19) - Copy (2).pptx
ssuser26e9871
Wizard's Portfolio by 際際滷sgo.pasdsaptx
Wizard's Portfolio by 際際滷sgo.pasdsaptxWizard's Portfolio by 際際滷sgo.pasdsaptx
Wizard's Portfolio by 際際滷sgo.pasdsaptx
CasadaInformtica
1-OLEOCHEMICAL and FATTY ALCOHOL OVERVIEW.pptx
1-OLEOCHEMICAL and FATTY ALCOHOL OVERVIEW.pptx1-OLEOCHEMICAL and FATTY ALCOHOL OVERVIEW.pptx
1-OLEOCHEMICAL and FATTY ALCOHOL OVERVIEW.pptx
HieuPham72153
AI Monday - Recognition (1) By Saoirse MacLaughlin
AI Monday - Recognition (1) By Saoirse MacLaughlinAI Monday - Recognition (1) By Saoirse MacLaughlin
AI Monday - Recognition (1) By Saoirse MacLaughlin
office377537
John Deere 540G, 640G, 740G Skidder & 548G, 648G, 748G Grapple Skidder Repair...
John Deere 540G, 640G, 740G Skidder & 548G, 648G, 748G Grapple Skidder Repair...John Deere 540G, 640G, 740G Skidder & 548G, 648G, 748G Grapple Skidder Repair...
John Deere 540G, 640G, 740G Skidder & 548G, 648G, 748G Grapple Skidder Repair...
Service Repair Manual
BMW AC Blowing Hot Air A Guide for Owners
BMW AC Blowing Hot Air A Guide for OwnersBMW AC Blowing Hot Air A Guide for Owners
BMW AC Blowing Hot Air A Guide for Owners
Terry Sayther Automotive
The Udenzes.pptxggggggggggggggggggggggggggggggg
The Udenzes.pptxgggggggggggggggggggggggggggggggThe Udenzes.pptxggggggggggggggggggggggggggggggg
The Udenzes.pptxggggggggggggggggggggggggggggggg
tobennaudenze
Troubleshooting Volkswagen AC Issues Professional Solutions for Optimal Cooli...
Troubleshooting Volkswagen AC Issues Professional Solutions for Optimal Cooli...Troubleshooting Volkswagen AC Issues Professional Solutions for Optimal Cooli...
Troubleshooting Volkswagen AC Issues Professional Solutions for Optimal Cooli...
Medway Imports
What is the engine problem with Mercedes
What is the engine problem with MercedesWhat is the engine problem with Mercedes
What is the engine problem with Mercedes
Das European Autohaus
鴛鰻意粥喝永姻看堰顎艶姻岳温喝珂温稼顎温鉛喝糸艶喝鉛温喝鞄顎艶姻岳温喝温乙姻看艶界看鉛坦乙庄界温.沿糸韓
鴛鰻意粥喝永姻看堰顎艶姻岳温喝珂温稼顎温鉛喝糸艶喝鉛温喝鞄顎艶姻岳温喝温乙姻看艶界看鉛坦乙庄界温.沿糸韓鴛鰻意粥喝永姻看堰顎艶姻岳温喝珂温稼顎温鉛喝糸艶喝鉛温喝鞄顎艶姻岳温喝温乙姻看艶界看鉛坦乙庄界温.沿糸韓
鴛鰻意粥喝永姻看堰顎艶姻岳温喝珂温稼顎温鉛喝糸艶喝鉛温喝鞄顎艶姻岳温喝温乙姻看艶界看鉛坦乙庄界温.沿糸韓
JuanPabloAcosta24
Future Automotive Manufacturing Process & Materials.pdf
Future Automotive Manufacturing Process & Materials.pdfFuture Automotive Manufacturing Process & Materials.pdf
Future Automotive Manufacturing Process & Materials.pdf
aabirforwork
Project about Electric vehicle report In
Project about Electric vehicle report InProject about Electric vehicle report In
Project about Electric vehicle report In
VMathewsMass
Why does my Mini Cooper car ride so rough
Why does my Mini Cooper car ride so roughWhy does my Mini Cooper car ride so rough
Why does my Mini Cooper car ride so rough
European Auto Tech
How to Troubleshoot and Fix Air Conditioning Issues in Your Land Rover
How to Troubleshoot and Fix Air Conditioning Issues in Your Land RoverHow to Troubleshoot and Fix Air Conditioning Issues in Your Land Rover
How to Troubleshoot and Fix Air Conditioning Issues in Your Land Rover
Autowerks
1. Rural sociology meaning.pptxblquschpchdjogsclkhc
1. Rural sociology meaning.pptxblquschpchdjogsclkhc1. Rural sociology meaning.pptxblquschpchdjogsclkhc
1. Rural sociology meaning.pptxblquschpchdjogsclkhc
movieshubs123
UAP Market Development Strategy Brandon, MB
UAP Market Development Strategy  Brandon, MBUAP Market Development Strategy  Brandon, MB
UAP Market Development Strategy Brandon, MB
Arda Ozbek

mod.ppt mod.ppt mod.ppt mod.ppt mod.pp d

  • 2. What are Modules? Modules are files containing Python definitions and statements (ex. name.py) A modules definitions can be imported into other modules by using import name The modules name is available as a global variable value To access a modules functions, type name.function()
  • 3. More on Modules Modules can contain executable statements along with function definitions Each module has its own private symbol table used as the global symbol table by all functions in the module Modules can import other modules Each module is imported once per interpreter session reload(name) Can import names from a module into the importing modules symbol table from mod import m1, m2 (or *) m1()
  • 4. Executing Modules python name.py <arguments> Runs code as if it was imported Setting _name_ == _main_ the file can be used as a script and an importable module
  • 5. The Module Search Path The interpreter searches for a file named name.py Current directory given by variable sys.path List of directories specified by PYTHONPATH Default path (in UNIX - .:/usr/local/lib/python) Script being run should not have the same name as a standard module or an error will occur when the module is imported
  • 6. Compiled Python Files If files mod.pyc and mod.py are in the same directory, there is a byte-compiled version of the module mod The modification time of the version of mod.py used to create mod.pyc is stored in mod.pyc Normally, the user does not need to do anything to create the .pyc file A compiled .py file is written to the .pyc No error for failed attempt, .pyc is recognized as invalid Contents of the .pyc can be shared by different machines
  • 7. Some Tips -O flag generates optimized code and stores it in .pyo files Only removes assert statements .pyc files are ignored and .py files are compiled to optimized bytecode Passing two OO flags Can result in malfunctioning programs _doc_ strings are removed Same speed when read from .pyc, .pyo, or .py files, .pyo and .pyc files are loaded faster Startup time of a script can be reduced by moving its code to a module and importing the module Can have a .pyc or .pyo file without having a .py file for the same module Module compileall creates .pyc or .pyo files for all modules in a directory
  • 8. Standard Modules Python comes with a library of standard modules described in the Python Library Reference Some are built into interpreter >>> import sys >>> sys.s1 >>> >>> sys.s1 = c> c> print Hello Hello c> sys.path determines the interpreterss search path for modules, with the default path taken from PYTHONPATH Can be modified with append() (ex. Sys.path.append(SOMEPATH)
  • 9. The dir() Function Used to find the names a module defines and returns a sorted list of strings >>> import mod >>> dir(mod) [_name_, m1, m2] Without arguments, it lists the names currently defined (variables, modules, functions, etc) Does not list names of built-in functions and variables Use _bulltin_to view all built-in functions and variables
  • 10. Packages dotted module names (ex. a.b) Submodule b in package a Saves authors of multi-module packages from worrying about each others module names Python searches through sys.path directories for the package subdirectory Users of the package can import individual modules from the package Ways to import submodules import sound.effects.echo from sound.effects import echo Submodules must be referenced by full name An ImportError exception is raised when the package cannot be found
  • 11. Importing * From a Package * does not import all submodules from a package Ensures that the package has been imported, only importing the names of the submodules defined in the package import sound.effects.echo import sound.effects.surround from sound.effects import *
  • 12. Intra-package References Submodules can refer to each other Surround might use echo module import echo also loads surround module import statement first looks in the containing package before looking in the standard module search path Absolute imports refer to submodules of sibling packages sound.filters.vocoder uses echo module from sound.effects import echo Can write explicit relative imports from . import echo from .. import formats from ..filters import equalizer
  • 13. Packages in Multiple Directories _path_ is a list containing the name of the directory holding the packages _init_.py Changing this variable can affect futute searches for modules and subpackages in the package Can be used to extend the set of modules in a package Not often needed