import sys # import the system defined sys module--you can use the # functions in sys as long as you prefix them with sys. import foo # import foo.py. You can use the functions in foo as long as # you prefix them with foo. from foo import min # import the min function from foo into the current namespace. # You can use min without qualification from foo import * # import all functions from foo into the current namespace. # You can use all functions in foo without qualification import sounds.effects.echo # import echo.py from the sounds.effects package # You can use the functions in echo as long as # you prefix them with the full package name # sounds.effects.echo. from sounds.effects import echo # You can use the functions in echo as # long as you prefix them with echo (you no # longer need the fully qualified package name) from sounds.effects import * # assume that effects is a directory. this # command does not work like you expect. See the # packages section below for details
silhouette/
__init__.py
graphics/
__init__.py
rect.py
circle.py
events/
__init__.py
mouse.py
keyboard.py
If you want the command
from silhouette.events import *
to import mouse.py and keyboard.py, then the
__init__.py file for events should be:
__all__ = ["mouse", "keyboard"]
Even after importing mouse and keyboard, you will still have to
access their functions by qualifying them with either mouse or
keyboard. If you omit the __all__ list, then nothing gets
imported unless the __init__.py file explicitly imports
certain modules