import import

- dive into Python import statement

Konrad Hałas (@konradhalas)

Few words about me

  • PyWaw co-organizer
  • developer in SUNSCRAPERS
  • MutPy author

Agenda

  • presentation purpose
  • basic info
  • syntax history
  • inside machinery
  • best practices
  • common problems

Presentation purpose

  • understand how import statement works
  • learn how to override standard import behavior
  • prepare to meet with "magic" import code in other projects
  • do it well and avoid problems

What is purpose of import statement?

  • it allows to use code from other modules
  • it allows to split code into multiple modules

What does import statement do?

  • find a module
  • initialize it if necessary
  • define a name or names in the local namespace

Syntax history

Python 1.0.0 - 1994

    import_stmt:  "import" identifier ("," identifier)*
                  | "from" identifier "import" identifier ("," identifier)*
                  | "from" identifier "import" "*"

Python 1.5.0 - 1997

    
    import_stmt:  "import" module ("," module)* 
                  | "from" module "import" identifier ("," identifier)*
                  | "from" module "import" "*" 
    module:       (identifier ".")* identifier

Python 2.0.0 - 2000

    import_stmt:  "import" module ["as" name] ("," module ["as" name] )* 
                  | "from" module "import" identifier ["as" name]
                  ("," identifier ["as" name] )*
                  | "from" module "import" "*" 
    module:       (identifier ".")* identifier

Python 2.5.0 - 2006

    import_stmt:       "import" module ["as" name] ( "," module ["as" name] )*
                       | "from" relative_module "import" identifier ["as" name]
                       ( "," identifier ["as" name] )*
                       | "from" relative_module "import" "(" identifier ["as" name]
                       ( "," identifier ["as" name] )* [","] ")"
                       | "from" module "import" "*"
    module :           (identifier ".")* identifier
    relative_module :  "."* module | "."+
    name :             identifier

import statement machinery

  • defined in PEP 302 ("New Import Hooks")
  • introduced in Python 2.3 (2003)
  • complete integration in Python 3.3 (2012)

Let's start...

Machinery structures

  1. sys.modules
  2. sys.meta_path
  3. sys.path
  4. sys.path_hooks
  5. sys.path_importer_cache

sys.modules

This is a dictionary that maps module names to modules which have already been loaded.

In [1]:
import sys

sys.modules
Out[1]:
{'IPython': <module 'IPython' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/__init__.py'>,
 'IPython.config': <module 'IPython.config' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/config/__init__.py'>,
 'IPython.config.application': <module 'IPython.config.application' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/config/application.py'>,
 'IPython.config.configurable': <module 'IPython.config.configurable' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/config/configurable.py'>,
 'IPython.config.loader': <module 'IPython.config.loader' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/config/loader.py'>,
 'IPython.core': <module 'IPython.core' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/__init__.py'>,
 'IPython.core.alias': <module 'IPython.core.alias' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/alias.py'>,
 'IPython.core.application': <module 'IPython.core.application' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/application.py'>,
 'IPython.core.autocall': <module 'IPython.core.autocall' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/autocall.py'>,
 'IPython.core.builtin_trap': <module 'IPython.core.builtin_trap' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/builtin_trap.py'>,
 'IPython.core.compilerop': <module 'IPython.core.compilerop' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/compilerop.py'>,
 'IPython.core.completer': <module 'IPython.core.completer' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/completer.py'>,
 'IPython.core.completerlib': <module 'IPython.core.completerlib' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/completerlib.py'>,
 'IPython.core.crashhandler': <module 'IPython.core.crashhandler' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/crashhandler.py'>,
 'IPython.core.debugger': <module 'IPython.core.debugger' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/debugger.py'>,
 'IPython.core.display': <module 'IPython.core.display' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/display.py'>,
 'IPython.core.display_trap': <module 'IPython.core.display_trap' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/display_trap.py'>,
 'IPython.core.displayhook': <module 'IPython.core.displayhook' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/displayhook.py'>,
 'IPython.core.displaypub': <module 'IPython.core.displaypub' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/displaypub.py'>,
 'IPython.core.error': <module 'IPython.core.error' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/error.py'>,
 'IPython.core.excolors': <module 'IPython.core.excolors' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/excolors.py'>,
 'IPython.core.extensions': <module 'IPython.core.extensions' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/extensions.py'>,
 'IPython.core.fakemodule': <module 'IPython.core.fakemodule' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/fakemodule.py'>,
 'IPython.core.formatters': <module 'IPython.core.formatters' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/formatters.py'>,
 'IPython.core.getipython': <module 'IPython.core.getipython' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/getipython.py'>,
 'IPython.core.history': <module 'IPython.core.history' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/history.py'>,
 'IPython.core.hooks': <module 'IPython.core.hooks' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/hooks.py'>,
 'IPython.core.inputsplitter': <module 'IPython.core.inputsplitter' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/inputsplitter.py'>,
 'IPython.core.inputtransformer': <module 'IPython.core.inputtransformer' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/inputtransformer.py'>,
 'IPython.core.interactiveshell': <module 'IPython.core.interactiveshell' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/interactiveshell.py'>,
 'IPython.core.logger': <module 'IPython.core.logger' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/logger.py'>,
 'IPython.core.macro': <module 'IPython.core.macro' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/macro.py'>,
 'IPython.core.magic': <module 'IPython.core.magic' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/magic.py'>,
 'IPython.core.magic_arguments': <module 'IPython.core.magic_arguments' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/magic_arguments.py'>,
 'IPython.core.magics': <module 'IPython.core.magics' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/magics/__init__.py'>,
 'IPython.core.magics.auto': <module 'IPython.core.magics.auto' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/magics/auto.py'>,
 'IPython.core.magics.basic': <module 'IPython.core.magics.basic' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/magics/basic.py'>,
 'IPython.core.magics.code': <module 'IPython.core.magics.code' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/magics/code.py'>,
 'IPython.core.magics.config': <module 'IPython.core.magics.config' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/magics/config.py'>,
 'IPython.core.magics.deprecated': <module 'IPython.core.magics.deprecated' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/magics/deprecated.py'>,
 'IPython.core.magics.display': <module 'IPython.core.magics.display' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/magics/display.py'>,
 'IPython.core.magics.execution': <module 'IPython.core.magics.execution' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/magics/execution.py'>,
 'IPython.core.magics.extension': <module 'IPython.core.magics.extension' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/magics/extension.py'>,
 'IPython.core.magics.history': <module 'IPython.core.magics.history' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/magics/history.py'>,
 'IPython.core.magics.logging': <module 'IPython.core.magics.logging' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/magics/logging.py'>,
 'IPython.core.magics.namespace': <module 'IPython.core.magics.namespace' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/magics/namespace.py'>,
 'IPython.core.magics.osm': <module 'IPython.core.magics.osm' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/magics/osm.py'>,
 'IPython.core.magics.pylab': <module 'IPython.core.magics.pylab' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/magics/pylab.py'>,
 'IPython.core.magics.script': <module 'IPython.core.magics.script' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/magics/script.py'>,
 'IPython.core.oinspect': <module 'IPython.core.oinspect' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/oinspect.py'>,
 'IPython.core.page': <module 'IPython.core.page' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/page.py'>,
 'IPython.core.payload': <module 'IPython.core.payload' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/payload.py'>,
 'IPython.core.payloadpage': <module 'IPython.core.payloadpage' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/payloadpage.py'>,
 'IPython.core.prefilter': <module 'IPython.core.prefilter' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/prefilter.py'>,
 'IPython.core.profiledir': <module 'IPython.core.profiledir' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/profiledir.py'>,
 'IPython.core.prompts': <module 'IPython.core.prompts' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/prompts.py'>,
 'IPython.core.pylabtools': <module 'IPython.core.pylabtools' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/pylabtools.py'>,
 'IPython.core.release': <module 'IPython.core.release' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/release.py'>,
 'IPython.core.shadowns': <module 'IPython.core.shadowns' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/shadowns.py'>,
 'IPython.core.shellapp': <module 'IPython.core.shellapp' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/shellapp.py'>,
 'IPython.core.splitinput': <module 'IPython.core.splitinput' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/splitinput.py'>,
 'IPython.core.ultratb': <module 'IPython.core.ultratb' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/ultratb.py'>,
 'IPython.core.usage': <module 'IPython.core.usage' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/usage.py'>,
 'IPython.display': <module 'IPython.display' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/display.py'>,
 'IPython.extensions': <module 'IPython.extensions' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/extensions/__init__.py'>,
 'IPython.extensions.storemagic': <module 'IPython.extensions.storemagic' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/extensions/storemagic.py'>,
 'IPython.external': <module 'IPython.external' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/__init__.py'>,
 'IPython.external.argparse': <module 'IPython.external.argparse' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/argparse/__init__.py'>,
 'IPython.external.decorator': <module 'IPython.external.decorator' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/decorator/__init__.py'>,
 'IPython.external.decorator._decorator': <module 'IPython.external.decorator._decorator' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/decorator/_decorator.py'>,
 'IPython.external.path': <module 'IPython.external.path' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/path/__init__.py'>,
 'IPython.external.path._path': <module 'IPython.external.path._path' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/path/_path.py'>,
 'IPython.external.pexpect': <module 'IPython.external.pexpect' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/pexpect/__init__.py'>,
 'IPython.external.pexpect._pexpect': <module 'IPython.external.pexpect._pexpect' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/pexpect/_pexpect.py'>,
 'IPython.external.simplegeneric': <module 'IPython.external.simplegeneric' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/simplegeneric/__init__.py'>,
 'IPython.external.simplegeneric._simplegeneric': <module 'IPython.external.simplegeneric._simplegeneric' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/simplegeneric/_simplegeneric.py'>,
 'IPython.external.ssh': <module 'IPython.external.ssh' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/ssh/__init__.py'>,
 'IPython.external.ssh.tunnel': <module 'IPython.external.ssh.tunnel' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/ssh/tunnel.py'>,
 'IPython.kernel': <module 'IPython.kernel' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/__init__.py'>,
 'IPython.kernel.blocking': <module 'IPython.kernel.blocking' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/blocking/__init__.py'>,
 'IPython.kernel.blocking.channels': <module 'IPython.kernel.blocking.channels' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/blocking/channels.py'>,
 'IPython.kernel.blocking.client': <module 'IPython.kernel.blocking.client' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/blocking/client.py'>,
 'IPython.kernel.channels': <module 'IPython.kernel.channels' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/channels.py'>,
 'IPython.kernel.channelsabc': <module 'IPython.kernel.channelsabc' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/channelsabc.py'>,
 'IPython.kernel.client': <module 'IPython.kernel.client' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/client.py'>,
 'IPython.kernel.clientabc': <module 'IPython.kernel.clientabc' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/clientabc.py'>,
 'IPython.kernel.connect': <module 'IPython.kernel.connect' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/connect.py'>,
 'IPython.kernel.inprocess': <module 'IPython.kernel.inprocess' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/inprocess/__init__.py'>,
 'IPython.kernel.inprocess.blocking': <module 'IPython.kernel.inprocess.blocking' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/inprocess/blocking.py'>,
 'IPython.kernel.inprocess.channels': <module 'IPython.kernel.inprocess.channels' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/inprocess/channels.py'>,
 'IPython.kernel.inprocess.client': <module 'IPython.kernel.inprocess.client' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/inprocess/client.py'>,
 'IPython.kernel.inprocess.manager': <module 'IPython.kernel.inprocess.manager' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/inprocess/manager.py'>,
 'IPython.kernel.inprocess.socket': <module 'IPython.kernel.inprocess.socket' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/inprocess/socket.py'>,
 'IPython.kernel.launcher': <module 'IPython.kernel.launcher' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/launcher.py'>,
 'IPython.kernel.manager': <module 'IPython.kernel.manager' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/manager.py'>,
 'IPython.kernel.managerabc': <module 'IPython.kernel.managerabc' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/managerabc.py'>,
 'IPython.kernel.multikernelmanager': <module 'IPython.kernel.multikernelmanager' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/multikernelmanager.py'>,
 'IPython.kernel.zmq': <module 'IPython.kernel.zmq' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/zmq/__init__.py'>,
 'IPython.kernel.zmq.datapub': <module 'IPython.kernel.zmq.datapub' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/zmq/datapub.py'>,
 'IPython.kernel.zmq.displayhook': <module 'IPython.kernel.zmq.displayhook' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/zmq/displayhook.py'>,
 'IPython.kernel.zmq.heartbeat': <module 'IPython.kernel.zmq.heartbeat' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/zmq/heartbeat.py'>,
 'IPython.kernel.zmq.iostream': <module 'IPython.kernel.zmq.iostream' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/zmq/iostream.py'>,
 'IPython.kernel.zmq.ipkernel': <module 'IPython.kernel.zmq.ipkernel' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/zmq/ipkernel.py'>,
 'IPython.kernel.zmq.kernelapp': <module 'IPython.kernel.zmq.kernelapp' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/zmq/kernelapp.py'>,
 'IPython.kernel.zmq.parentpoller': <module 'IPython.kernel.zmq.parentpoller' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/zmq/parentpoller.py'>,
 'IPython.kernel.zmq.serialize': <module 'IPython.kernel.zmq.serialize' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/zmq/serialize.py'>,
 'IPython.kernel.zmq.session': <module 'IPython.kernel.zmq.session' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/zmq/session.py'>,
 'IPython.kernel.zmq.zmqshell': <module 'IPython.kernel.zmq.zmqshell' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/zmq/zmqshell.py'>,
 'IPython.lib': <module 'IPython.lib' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/lib/__init__.py'>,
 'IPython.lib.backgroundjobs': <module 'IPython.lib.backgroundjobs' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/lib/backgroundjobs.py'>,
 'IPython.lib.deepreload': <module 'IPython.lib.deepreload' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/lib/deepreload.py'>,
 'IPython.lib.display': <module 'IPython.lib.display' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/lib/display.py'>,
 'IPython.lib.inputhook': <module 'IPython.lib.inputhook' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/lib/inputhook.py'>,
 'IPython.lib.latextools': <module 'IPython.lib.latextools' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/lib/latextools.py'>,
 'IPython.lib.pretty': <module 'IPython.lib.pretty' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/lib/pretty.py'>,
 'IPython.lib.security': <module 'IPython.lib.security' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/lib/security.py'>,
 'IPython.terminal': <module 'IPython.terminal' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/terminal/__init__.py'>,
 'IPython.terminal.embed': <module 'IPython.terminal.embed' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/terminal/embed.py'>,
 'IPython.terminal.interactiveshell': <module 'IPython.terminal.interactiveshell' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/terminal/interactiveshell.py'>,
 'IPython.terminal.ipapp': <module 'IPython.terminal.ipapp' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/terminal/ipapp.py'>,
 'IPython.testing': <module 'IPython.testing' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/testing/__init__.py'>,
 'IPython.testing.skipdoctest': <module 'IPython.testing.skipdoctest' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/testing/skipdoctest.py'>,
 'IPython.utils': <module 'IPython.utils' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/__init__.py'>,
 'IPython.utils.PyColorize': <module 'IPython.utils.PyColorize' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/PyColorize.py'>,
 'IPython.utils._process_common': <module 'IPython.utils._process_common' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/_process_common.py'>,
 'IPython.utils._process_posix': <module 'IPython.utils._process_posix' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/_process_posix.py'>,
 'IPython.utils._sysinfo': <module 'IPython.utils._sysinfo' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/_sysinfo.py'>,
 'IPython.utils._tokenize_py3': <module 'IPython.utils._tokenize_py3' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/_tokenize_py3.py'>,
 'IPython.utils.codeutil': <module 'IPython.utils.codeutil' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/codeutil.py'>,
 'IPython.utils.coloransi': <module 'IPython.utils.coloransi' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/coloransi.py'>,
 'IPython.utils.contexts': <module 'IPython.utils.contexts' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/contexts.py'>,
 'IPython.utils.data': <module 'IPython.utils.data' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/data.py'>,
 'IPython.utils.decorators': <module 'IPython.utils.decorators' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/decorators.py'>,
 'IPython.utils.dir2': <module 'IPython.utils.dir2' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/dir2.py'>,
 'IPython.utils.encoding': <module 'IPython.utils.encoding' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/encoding.py'>,
 'IPython.utils.frame': <module 'IPython.utils.frame' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/frame.py'>,
 'IPython.utils.generics': <module 'IPython.utils.generics' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/generics.py'>,
 'IPython.utils.importstring': <module 'IPython.utils.importstring' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/importstring.py'>,
 'IPython.utils.io': <module 'IPython.utils.io' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/io.py'>,
 'IPython.utils.ipstruct': <module 'IPython.utils.ipstruct' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/ipstruct.py'>,
 'IPython.utils.jsonutil': <module 'IPython.utils.jsonutil' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/jsonutil.py'>,
 'IPython.utils.localinterfaces': <module 'IPython.utils.localinterfaces' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/localinterfaces.py'>,
 'IPython.utils.module_paths': <module 'IPython.utils.module_paths' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/module_paths.py'>,
 'IPython.utils.nested_context': <module 'IPython.utils.nested_context' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/nested_context.py'>,
 'IPython.utils.openpy': <module 'IPython.utils.openpy' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/openpy.py'>,
 'IPython.utils.path': <module 'IPython.utils.path' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/path.py'>,
 'IPython.utils.pickleshare': <module 'IPython.utils.pickleshare' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/pickleshare.py'>,
 'IPython.utils.pickleutil': <module 'IPython.utils.pickleutil' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/pickleutil.py'>,
 'IPython.utils.process': <module 'IPython.utils.process' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/process.py'>,
 'IPython.utils.py3compat': <module 'IPython.utils.py3compat' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/py3compat.py'>,
 'IPython.utils.rlineimpl': <module 'IPython.utils.rlineimpl' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/rlineimpl.py'>,
 'IPython.utils.strdispatch': <module 'IPython.utils.strdispatch' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/strdispatch.py'>,
 'IPython.utils.sysinfo': <module 'IPython.utils.sysinfo' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/sysinfo.py'>,
 'IPython.utils.syspathcontext': <module 'IPython.utils.syspathcontext' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/syspathcontext.py'>,
 'IPython.utils.terminal': <module 'IPython.utils.terminal' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/terminal.py'>,
 'IPython.utils.text': <module 'IPython.utils.text' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/text.py'>,
 'IPython.utils.timing': <module 'IPython.utils.timing' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/timing.py'>,
 'IPython.utils.tokenize2': <module 'IPython.utils.tokenize2' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/tokenize2.py'>,
 'IPython.utils.traitlets': <module 'IPython.utils.traitlets' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/traitlets.py'>,
 'IPython.utils.ulinecache': <module 'IPython.utils.ulinecache' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/ulinecache.py'>,
 'IPython.utils.version': <module 'IPython.utils.version' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/version.py'>,
 'IPython.utils.warn': <module 'IPython.utils.warn' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/warn.py'>,
 'IPython.utils.wildcard': <module 'IPython.utils.wildcard' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/wildcard.py'>,
 'IPython.utils.zmqrelated': <module 'IPython.utils.zmqrelated' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils/zmqrelated.py'>,
 '__future__': <module '__future__' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/__future__.py'>,
 '__main__': <module '__main__'>,
 '_ast': <module '_ast' (built-in)>,
 '_bisect': <module '_bisect' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/lib-dynload/_bisect.so'>,
 '_bz2': <module '_bz2' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/_bz2.so'>,
 '_codecs': <module '_codecs' (built-in)>,
 '_collections': <module '_collections' (built-in)>,
 '_compat_pickle': <module '_compat_pickle' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/_compat_pickle.py'>,
 '_ctypes': <module '_ctypes' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/_ctypes.so'>,
 '_curses': <module '_curses' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/_curses.so'>,
 '_datetime': <module '_datetime' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/_datetime.so'>,
 '_frozen_importlib': <module 'importlib._bootstrap' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/importlib/_bootstrap.py'>,
 '_functools': <module '_functools' (built-in)>,
 '_hashlib': <module '_hashlib' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/_hashlib.so'>,
 '_heapq': <module '_heapq' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/lib-dynload/_heapq.so'>,
 '_imp': <module '_imp' (built-in)>,
 '_io': <module 'io' (built-in)>,
 '_json': <module '_json' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/_json.so'>,
 '_locale': <module '_locale' (built-in)>,
 '_lsprof': <module '_lsprof' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/_lsprof.so'>,
 '_multiprocessing': <module '_multiprocessing' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/_multiprocessing.so'>,
 '_osx_support': <module '_osx_support' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/_osx_support.py'>,
 '_pickle': <module '_pickle' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/_pickle.so'>,
 '_posixsubprocess': <module '_posixsubprocess' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/_posixsubprocess.so'>,
 '_random': <module '_random' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/_random.so'>,
 '_socket': <module '_socket' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/_socket.so'>,
 '_sqlite3': <module '_sqlite3' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/_sqlite3.so'>,
 '_sre': <module '_sre' (built-in)>,
 '_string': <module '_string' (built-in)>,
 '_strptime': <module '_strptime' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/_strptime.py'>,
 '_struct': <module '_struct' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/_struct.so'>,
 '_thread': <module '_thread' (built-in)>,
 '_virtualenv_distutils': <module '_virtualenv_distutils' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/__init__.py'>,
 '_warnings': <module '_warnings' (built-in)>,
 '_weakref': <module '_weakref' (built-in)>,
 '_weakrefset': <module '_weakrefset' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/_weakrefset.py'>,
 'abc': <module 'abc' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/abc.py'>,
 'argparse': <module 'argparse' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/argparse.py'>,
 'array': <module 'array' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/array.so'>,
 'ast': <module 'ast' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/ast.py'>,
 'atexit': <module 'atexit' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/atexit.so'>,
 'base64': <module 'base64' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/base64.py'>,
 'bdb': <module 'bdb' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/bdb.py'>,
 'binascii': <module 'binascii' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/binascii.so'>,
 'bisect': <module 'bisect' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/bisect.py'>,
 'builtins': <module 'builtins'>,
 'bz2': <module 'bz2' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/bz2.py'>,
 'cProfile': <module 'cProfile' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/cProfile.py'>,
 'calendar': <module 'calendar' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/calendar.py'>,
 'cmd': <module 'cmd' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/cmd.py'>,
 'code': <module 'code' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/code.py'>,
 'codecs': <module 'codecs' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/codecs.py'>,
 'codeop': <module 'codeop' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/codeop.py'>,
 'collections': <module 'collections' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/collections/__init__.py'>,
 'collections.abc': <module 'collections.abc' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/collections/abc.py'>,
 'concurrent': <module 'concurrent' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/concurrent/__init__.py'>,
 'concurrent.futures': <module 'concurrent.futures' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/concurrent/futures/__init__.py'>,
 'concurrent.futures._base': <module 'concurrent.futures._base' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/concurrent/futures/_base.py'>,
 'concurrent.futures.process': <module 'concurrent.futures.process' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/concurrent/futures/process.py'>,
 'concurrent.futures.thread': <module 'concurrent.futures.thread' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/concurrent/futures/thread.py'>,
 'contextlib': <module 'contextlib' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/contextlib.py'>,
 'copy': <module 'copy' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/copy.py'>,
 'copyreg': <module 'copyreg' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/copyreg.py'>,
 'ctypes': <module 'ctypes' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/ctypes/__init__.py'>,
 'ctypes._endian': <module 'ctypes._endian' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/ctypes/_endian.py'>,
 'ctypes.macholib': <module 'ctypes.macholib' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/ctypes/macholib/__init__.py'>,
 'ctypes.macholib.dyld': <module 'ctypes.macholib.dyld' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/ctypes/macholib/dyld.py'>,
 'ctypes.macholib.dylib': <module 'ctypes.macholib.dylib' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/ctypes/macholib/dylib.py'>,
 'ctypes.macholib.framework': <module 'ctypes.macholib.framework' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/ctypes/macholib/framework.py'>,
 'ctypes.util': <module 'ctypes.util' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/ctypes/util.py'>,
 'curses': <module 'curses' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/curses/__init__.py'>,
 'datetime': <module 'datetime' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/datetime.py'>,
 'dis': <module 'dis' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/dis.py'>,
 'distutils': <module 'distutils' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/distutils/__init__.py'>,
 'distutils.debug': <module 'distutils.debug' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/debug.py'>,
 'distutils.dep_util': <module 'distutils.dep_util' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/dep_util.py'>,
 'distutils.dist': <module 'distutils.dist' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/dist.py'>,
 'distutils.errors': <module 'distutils.errors' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/errors.py'>,
 'distutils.fancy_getopt': <module 'distutils.fancy_getopt' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/fancy_getopt.py'>,
 'distutils.log': <module 'distutils.log' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/log.py'>,
 'distutils.spawn': <module 'distutils.spawn' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/spawn.py'>,
 'distutils.sysconfig': <module 'distutils.sysconfig' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/sysconfig.py'>,
 'distutils.text_file': <module 'distutils.text_file' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/text_file.py'>,
 'distutils.util': <module 'distutils.util' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/util.py'>,
 'distutils.version': <module 'distutils.version' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/version.py'>,
 'encodings': <module 'encodings' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/encodings/__init__.py'>,
 'encodings.aliases': <module 'encodings.aliases' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/encodings/aliases.py'>,
 'encodings.idna': <module 'encodings.idna' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/encodings/idna.py'>,
 'encodings.latin_1': <module 'encodings.latin_1' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/encodings/latin_1.py'>,
 'encodings.utf_8': <module 'encodings.utf_8' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/encodings/utf_8.py'>,
 'errno': <module 'errno' (built-in)>,
 'fcntl': <module 'fcntl' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/fcntl.so'>,
 'fnmatch': <module 'fnmatch' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/fnmatch.py'>,
 'functools': <module 'functools' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/functools.py'>,
 'gc': <module 'gc' (built-in)>,
 'genericpath': <module 'genericpath' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/genericpath.py'>,
 'getopt': <module 'getopt' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/getopt.py'>,
 'getpass': <module 'getpass' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/getpass.py'>,
 'gettext': <module 'gettext' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/gettext.py'>,
 'glob': <module 'glob' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/glob.py'>,
 'grp': <module 'grp' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/grp.so'>,
 'hashlib': <module 'hashlib' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/hashlib.py'>,
 'heapq': <module 'heapq' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/heapq.py'>,
 'hmac': <module 'hmac' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/hmac.py'>,
 'html': <module 'html' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/html/__init__.py'>,
 'html.entities': <module 'html.entities' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/html/entities.py'>,
 'imp': <module 'imp' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/imp.py'>,
 'importlib': <module 'importlib' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/importlib/__init__.py'>,
 'importlib._bootstrap': <module 'importlib._bootstrap' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/importlib/_bootstrap.py'>,
 'importlib.machinery': <module 'importlib.machinery' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/importlib/machinery.py'>,
 'inspect': <module 'inspect' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/inspect.py'>,
 'io': <module 'io' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/io.py'>,
 'itertools': <module 'itertools' (built-in)>,
 'json': <module 'json' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/json/__init__.py'>,
 'json.decoder': <module 'json.decoder' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/json/decoder.py'>,
 'json.encoder': <module 'json.encoder' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/json/encoder.py'>,
 'json.scanner': <module 'json.scanner' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/json/scanner.py'>,
 'keyword': <module 'keyword' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/keyword.py'>,
 'linecache': <module 'linecache' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/linecache.py'>,
 'locale': <module 'locale' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/locale.py'>,
 'logging': <module 'logging' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/logging/__init__.py'>,
 'logging.handlers': <module 'logging.handlers' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/logging/handlers.py'>,
 'marshal': <module 'marshal' (built-in)>,
 'math': <module 'math' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/math.so'>,
 'multiprocessing': <module 'multiprocessing' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/multiprocessing/__init__.py'>,
 'multiprocessing.connection': <module 'multiprocessing.connection' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/multiprocessing/connection.py'>,
 'multiprocessing.forking': <module 'multiprocessing.forking' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/multiprocessing/forking.py'>,
 'multiprocessing.process': <module 'multiprocessing.process' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/multiprocessing/process.py'>,
 'multiprocessing.queues': <module 'multiprocessing.queues' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/multiprocessing/queues.py'>,
 'multiprocessing.reduction': <module 'multiprocessing.reduction' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/multiprocessing/reduction.py'>,
 'multiprocessing.synchronize': <module 'multiprocessing.synchronize' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/multiprocessing/synchronize.py'>,
 'multiprocessing.util': <module 'multiprocessing.util' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/multiprocessing/util.py'>,
 'numbers': <module 'numbers' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/numbers.py'>,
 'opcode': <module 'opcode' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/opcode.py'>,
 'operator': <module 'operator' (built-in)>,
 'os': <module 'os' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/os.py'>,
 'os.path': <module 'posixpath' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/posixpath.py'>,
 'pdb': <module 'pdb' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/pdb.py'>,
 'pickle': <module 'pickle' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/pickle.py'>,
 'pkgutil': <module 'pkgutil' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/pkgutil.py'>,
 'platform': <module 'platform' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/platform.py'>,
 'posix': <module 'posix' (built-in)>,
 'posixpath': <module 'posixpath' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/posixpath.py'>,
 'pprint': <module 'pprint' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/pprint.py'>,
 'pstats': <module 'pstats' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/pstats.py'>,
 'pty': <module 'pty' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/pty.py'>,
 'pwd': <module 'pwd' (built-in)>,
 'pydoc': <module 'pydoc' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/pydoc.py'>,
 'queue': <module 'queue' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/queue.py'>,
 'random': <module 'random' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/random.py'>,
 're': <module 're' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/re.py'>,
 'readline': <module 'readline' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/readline.so'>,
 'reprlib': <module 'reprlib' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/reprlib.py'>,
 'resource': <module 'resource' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/resource.so'>,
 'runpy': <module 'runpy' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/runpy.py'>,
 'select': <module 'select' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/select.so'>,
 'shlex': <module 'shlex' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/shlex.py'>,
 'shutil': <module 'shutil' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/shutil.py'>,
 'signal': <module 'signal'>,
 'site': <module 'site' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/site.py'>,
 'socket': <module 'socket' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/socket.py'>,
 'sqlite3': <module 'sqlite3' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/sqlite3/__init__.py'>,
 'sqlite3.dbapi2': <module 'sqlite3.dbapi2' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/sqlite3/dbapi2.py'>,
 'sre_compile': <module 'sre_compile' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/sre_compile.py'>,
 'sre_constants': <module 'sre_constants' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/sre_constants.py'>,
 'sre_parse': <module 'sre_parse' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/sre_parse.py'>,
 'stat': <module 'stat' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/stat.py'>,
 'storemagic': <module 'storemagic' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/extensions/storemagic.py'>,
 'string': <module 'string' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/string.py'>,
 'stringprep': <module 'stringprep' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/stringprep.py'>,
 'struct': <module 'struct' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/struct.py'>,
 'subprocess': <module 'subprocess' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/subprocess.py'>,
 'sys': <module 'sys' (built-in)>,
 'tarfile': <module 'tarfile' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/tarfile.py'>,
 'tempfile': <module 'tempfile' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/tempfile.py'>,
 'termios': <module 'termios' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/termios.so'>,
 'textwrap': <module 'textwrap' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/textwrap.py'>,
 'threading': <module 'threading' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/threading.py'>,
 'time': <module 'time' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/time.so'>,
 'token': <module 'token' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/token.py'>,
 'tokenize': <module 'tokenize' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/tokenize.py'>,
 'tornado': <module 'tornado' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/tornado/__init__.py'>,
 'tornado.concurrent': <module 'tornado.concurrent' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/tornado/concurrent.py'>,
 'tornado.escape': <module 'tornado.escape' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/tornado/escape.py'>,
 'tornado.ioloop': <module 'tornado.ioloop' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/tornado/ioloop.py'>,
 'tornado.log': <module 'tornado.log' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/tornado/log.py'>,
 'tornado.platform': <module 'tornado.platform' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/tornado/platform/__init__.py'>,
 'tornado.platform.auto': <module 'tornado.platform.auto' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/tornado/platform/auto.py'>,
 'tornado.platform.interface': <module 'tornado.platform.interface' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/tornado/platform/interface.py'>,
 'tornado.platform.posix': <module 'tornado.platform.posix' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/tornado/platform/posix.py'>,
 'tornado.stack_context': <module 'tornado.stack_context' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/tornado/stack_context.py'>,
 'tornado.util': <module 'tornado.util' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/tornado/util.py'>,
 'traceback': <module 'traceback' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/traceback.py'>,
 'tty': <module 'tty' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/tty.py'>,
 'types': <module 'types' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/types.py'>,
 'unicodedata': <module 'unicodedata' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/unicodedata.so'>,
 'urllib': <module 'urllib' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/urllib/__init__.py'>,
 'urllib.parse': <module 'urllib.parse' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/urllib/parse.py'>,
 'uuid': <module 'uuid' from '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/uuid.py'>,
 'warnings': <module 'warnings' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/warnings.py'>,
 'weakref': <module 'weakref' from '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/weakref.py'>,
 'zipimport': <module 'zipimport' (built-in)>,
 'zlib': <module 'zlib' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload/zlib.so'>,
 'zmq': <module 'zmq' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/__init__.py'>,
 'zmq.core': <module 'zmq.core' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/core/__init__.py'>,
 'zmq.core._device': <module 'zmq.core._device' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/core/_device.so'>,
 'zmq.core._poll': <module 'zmq.core._poll' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/core/_poll.so'>,
 'zmq.core._version': <module 'zmq.core._version' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/core/_version.so'>,
 'zmq.core.constants': <module 'zmq.core.constants' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/core/constants.so'>,
 'zmq.core.context': <module 'zmq.core.context' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/core/context.so'>,
 'zmq.core.error': <module 'zmq.core.error' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/core/error.so'>,
 'zmq.core.message': <module 'zmq.core.message' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/core/message.so'>,
 'zmq.core.socket': <module 'zmq.core.socket' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/core/socket.so'>,
 'zmq.core.stopwatch': <module 'zmq.core.stopwatch' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/core/stopwatch.so'>,
 'zmq.devices': <module 'zmq.devices' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/devices/__init__.py'>,
 'zmq.devices.basedevice': <module 'zmq.devices.basedevice' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/devices/basedevice.py'>,
 'zmq.devices.monitoredqueue': <module 'zmq.devices.monitoredqueue' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/devices/monitoredqueue.so'>,
 'zmq.devices.monitoredqueuedevice': <module 'zmq.devices.monitoredqueuedevice' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/devices/monitoredqueuedevice.py'>,
 'zmq.devices.proxydevice': <module 'zmq.devices.proxydevice' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/devices/proxydevice.py'>,
 'zmq.error': <module 'zmq.error' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/error.py'>,
 'zmq.eventloop': <module 'zmq.eventloop' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/eventloop/__init__.py'>,
 'zmq.eventloop.ioloop': <module 'zmq.eventloop.ioloop' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/eventloop/ioloop.py'>,
 'zmq.eventloop.minitornado': <module 'zmq.eventloop.minitornado' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/eventloop/minitornado/__init__.py'>,
 'zmq.eventloop.minitornado.stack_context': <module 'zmq.eventloop.minitornado.stack_context' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/eventloop/minitornado/stack_context.py'>,
 'zmq.eventloop.minitornado.util': <module 'zmq.eventloop.minitornado.util' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/eventloop/minitornado/util.py'>,
 'zmq.eventloop.zmqstream': <module 'zmq.eventloop.zmqstream' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/eventloop/zmqstream.py'>,
 'zmq.sugar': <module 'zmq.sugar' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/sugar/__init__.py'>,
 'zmq.sugar.attrsettr': <module 'zmq.sugar.attrsettr' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/sugar/attrsettr.py'>,
 'zmq.sugar.backend': <module 'zmq.sugar.backend' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/sugar/backend.py'>,
 'zmq.sugar.constants': <module 'zmq.sugar.constants' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/sugar/constants.py'>,
 'zmq.sugar.context': <module 'zmq.sugar.context' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/sugar/context.py'>,
 'zmq.sugar.frame': <module 'zmq.sugar.frame' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/sugar/frame.py'>,
 'zmq.sugar.poll': <module 'zmq.sugar.poll' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/sugar/poll.py'>,
 'zmq.sugar.socket': <module 'zmq.sugar.socket' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/sugar/socket.py'>,
 'zmq.sugar.tracker': <module 'zmq.sugar.tracker' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/sugar/tracker.py'>,
 'zmq.sugar.version': <module 'zmq.sugar.version' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/sugar/version.py'>,
 'zmq.utils': <module 'zmq.utils' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/utils/__init__.py'>,
 'zmq.utils.initthreads': <module 'zmq.utils.initthreads' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/utils/initthreads.so'>,
 'zmq.utils.jsonapi': <module 'zmq.utils.jsonapi' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/utils/jsonapi.py'>,
 'zmq.utils.strtypes': <module 'zmq.utils.strtypes' from '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/utils/strtypes.py'>}

sys.meta_path

A list of finder objects that have their find_module() methods called to see if one of the objects can find the module to be imported.

In [2]:
sys.meta_path
Out[2]:
[_frozen_importlib.BuiltinImporter,
 _frozen_importlib.FrozenImporter,
 _frozen_importlib.PathFinder]

Module finder

  • it must implement find_module(fullname, paths=None) method
    • fullname - fully qualified name of the module
    • paths - list of paths
  • it should return a loader object if the module was found, or None if it wasn't

DummyFinder - example

In [3]:
class DummyFinder:
    
    def find_module(self, fullname, paths=None):
        print('find_module - fullname: {}, paths: {}'.format(fullname, paths))
        return None
        
sys.meta_path.insert(0, DummyFinder())
In [4]:
sys.path.append('./workspace/')
In [5]:
import eggs
find_module - fullname: eggs, paths: None
In [6]:
from spam import bacon
find_module - fullname: spam, paths: None
find_module - fullname: spam.bacon, paths: ['./workspace/spam']
In [7]:
del sys.modules['spam']
del sys.modules['spam.bacon']
In [8]:
import spam.bacon
find_module - fullname: spam, paths: None
find_module - fullname: spam.bacon, paths: ['./workspace/spam']
In [9]:
'eggs' in sys.modules
Out[9]:
True
In [10]:
'spam' in sys.modules
Out[10]:
True
In [11]:
'spam.bacon' in sys.modules
Out[11]:
True
In [12]:
del sys.meta_path[0]
del sys.modules['eggs']
del sys.modules['spam']
del sys.modules['spam.bacon']

Module finder should return a module loader object

Module loader

  • loader is typically returned by a finder
  • it must define load_module(fullname) method
  • this method should return the loaded module or raise ImportError exception

DummyLoader - example

In [13]:
class DummyFinder:
    
    def find_module(self, fullname, paths=None):
        print('find_module - fullname: {}, paths: {}'.format(fullname, paths))
        if fullname == 'eggs':
            return DummyLoader()
        else:
            return None
        
class DummyLoader:
    
    def load_module(self, fullname):
        print('load_module - fullname: {}'.format(fullname))
        raise ImportError('spam spam spam')
        
sys.meta_path.insert(0, DummyFinder())
In [14]:
import eggs
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-14-5de045e19dc5> in <module>()
----> 1 import eggs

<ipython-input-13-96b35398c59f> in load_module(self, fullname)
     12     def load_module(self, fullname):
     13         print('load_module - fullname: {}'.format(fullname))
---> 14         raise ImportError('spam spam spam')
     15 
     16 sys.meta_path.insert(0, DummyFinder())

ImportError: spam spam spam
find_module - fullname: eggs, paths: None
load_module - fullname: eggs
In [15]:
del sys.meta_path[0]
find_module - fullname: zmq.core.zmq, paths: ['/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/core']
find_module - fullname: zmq.core.zmq, paths: ['/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/core']

finder + loader == importer

In [16]:
class DummyImporter:
    
    def find_module(self, fullname, paths=None):
        print('find_module - fullname: {}, paths: {}'.format(fullname, paths))
        if fullname == 'eggs':
            return self
        else:
            return None
    
    def load_module(self, fullname):
        print('load_module - fullname: {}'.format(fullname))
        raise ImportError('spam spam spam')
        
sys.meta_path.insert(0, DummyImporter())
In [17]:
del sys.meta_path[0]

load_module method responsibilities

  1. it must create empty module and add it to sys.modules or use existing one
  2. it may set the __file__ attribute of the module
  3. it may set the __name__ attribute of the module
  4. if the module is a package, it must set the module __path__ attribute
  5. it must set the module __loader__ attribute
  6. it may set the __package__ attribute of the module
  7. if the module is a Python module, it should execute the module’s code
  8. it must return created module

DynamicImporter - example

In [18]:
import types

class DynamicImporter:

    def __init__(self, name, code):
        self.name = name
        self.code = code

    def find_module(self, name, path):
        if name == self.name:
            return self
        else:
            return None

    def load_module(self, name):
        if name in sys.modules:
            module = sys.modules[name]
        else:
            module = types.ModuleType(name)
            sys.modules[name] = module
        module.__loader__ = self
        exec(self.code, module.__dict__)
        return module
In [19]:
sys.meta_path.insert(0, DynamicImporter(name='spam', code='eggs = True'))

import spam

print(spam.eggs)
True
In [20]:
del sys.meta_path[0]

Circular dependency example

# a.py

import b

X = 1

# b.py

import a

print(a.X)
In [21]:
import a
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-21-370c047e3c7f> in <module>()
----> 1 import a

/Users/konradhalas/dev/workspace/personal/import_import_presentation/workspace/a.py in <module>()
----> 1 import b
      2 
      3 X = 1

/Users/konradhalas/dev/workspace/personal/import_import_presentation/workspace/b.py in <module>()
      1 import a
      2 
----> 3 print(a.X)

AttributeError: 'module' object has no attribute 'X'

Circular dependency solution

  • merge modules
  • extract common artefacts
  • defer import (put it into method body)

How "normal" import works?

In [22]:
sys.meta_path
Out[22]:
[_frozen_importlib.BuiltinImporter,
 _frozen_importlib.FrozenImporter,
 _frozen_importlib.PathFinder]

Machinery structures

  1. sys.modules
  2. sys.meta_path
  3. sys.path
  4. sys.path_hooks
  5. sys.path_importer_cache

PathFinder - path based finder

  1. iterates over sys.path
  2. for each path entry in sys.path iterates over every callable in sys.path_hooks
  3. each of the path entry hooks in sys.path_hooks is called with a single argument - path
  4. path entry hook should return path entry finder or raise ImportError
  5. returend path entry finder is cached in sys.path_importer_cache
  6. call find_loader method on returned path entry finder with a single argument - fully qualified module name
  7. this method should return loader (and namespace portion) or raise ImportError
In [23]:
sys.path_hooks
Out[23]:
[zipimport.zipimporter, <function _frozen_importlib.path_hook_for_FileFinder>]
In [24]:
sys.path_importer_cache
Out[24]:
{'.': FileFinder('.'),
 './workspace/': FileFinder('./workspace/'),
 './workspace/spam': FileFinder('./workspace/spam'),
 '/Users/konradhalas/.ipython/extensions': FileFinder('/Users/konradhalas/.ipython/extensions'),
 '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/'),
 '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/collections': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/collections'),
 '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/encodings': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/encodings'),
 '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/lib-dynload': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/lib-dynload'),
 '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/plat-darwin': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python3.3/plat-darwin'),
 '/Users/konradhalas/dev/virtualenvs/import_import/bin/../lib/python33.zip': None,
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/importlib': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/importlib'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/lib-dynload'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/plat-darwin': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/plat-darwin'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/config': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/config'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/magics': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/core/magics'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/extensions': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/extensions'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/decorator': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/decorator'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/path': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/path'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/pexpect': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/pexpect'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/simplegeneric': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/simplegeneric'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/ssh': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/external/ssh'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/blocking': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/blocking'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/inprocess': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/inprocess'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/zmq': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/kernel/zmq'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/lib': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/lib'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/terminal': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/terminal'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/testing': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/testing'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/IPython/utils'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/distribute-0.6.31-py3.3.egg': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/distribute-0.6.31-py3.3.egg'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/pip-1.2.1-py3.3.egg': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/pip-1.2.1-py3.3.egg'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/tornado': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/tornado'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/tornado/platform': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/tornado/platform'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/core': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/core'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/devices': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/devices'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/eventloop': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/eventloop'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/eventloop/minitornado': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/eventloop/minitornado'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/sugar': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/sugar'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/utils': FileFinder('/Users/konradhalas/dev/virtualenvs/import_import/lib/python3.3/site-packages/zmq/utils'),
 '/Users/konradhalas/dev/virtualenvs/import_import/lib/python33.zip': None,
 '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3': FileFinder('/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3'),
 '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/concurrent': FileFinder('/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/concurrent'),
 '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/concurrent/futures': FileFinder('/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/concurrent/futures'),
 '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/ctypes': FileFinder('/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/ctypes'),
 '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/ctypes/macholib': FileFinder('/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/ctypes/macholib'),
 '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils': FileFinder('/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils'),
 '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/html': FileFinder('/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/html'),
 '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/json': FileFinder('/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/json'),
 '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/logging': FileFinder('/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/logging'),
 '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/multiprocessing': FileFinder('/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/multiprocessing'),
 '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/plat-darwin': FileFinder('/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/plat-darwin'),
 '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/sqlite3': FileFinder('/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/sqlite3'),
 '/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/urllib': FileFinder('/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/urllib')}
In [25]:
def http_path_entry_hook(path):
    if path.startswith('http://') or path.startswith('https://'):
        return HttpPathEntryFinder(path)
    else:
        raise ImportError()
In [26]:
import requests

class HttpPathEntryFinder:

    def __init__(self, path):
        self.path = path

    def find_loader(self, name):
        url = self.path + name + '.py'
        if requests.head(url).status_code == 200:
            return HttpLoader(url), None
        else:
            raise ImportError()
In [27]:
class HttpLoader:

    def __init__(self, url):
        self.url = url

    def load_module(self, name):
        if name in sys.modules:
            module = sys.modules[name]
        else:
            module = types.ModuleType(name)
            sys.modules[name] = module
        module.__loader__ = self
        module.__file__ = self.url
        response = requests.get(self.url)
        exec(response.content, module.__dict__)
        return module
In [28]:
sys.path_hooks.insert(0, http_path_entry_hook)
sys.path.append('https://raw.github.com/jcrocholl/pep8/master/')
In [29]:
import pep8
In [30]:
pep8
Out[30]:
<module 'pep8' from 'https://raw.github.com/jcrocholl/pep8/master/pep8.py'>
In [31]:
pep8.Checker(lines=['x  +  y\n']).check_all()
stdin:1:2: E221 multiple spaces before operator
stdin:1:5: E222 multiple spaces after operator
Out[31]:
2
In [32]:
del sys.path[-1]
del sys.path_hooks[0]
del sys.modules['pep8']

Good import practices

  • put all imports at the top of the file
  • divide imports into 3 sections by blank lines:
    • Python modules
    • third-party modules
    • your modules
  • put two blank lines after last section
  • each section should be sorted alphabetically
  • only one import should be on each line
  • avoid star imports
  • don't import single artefact, import whole module
  • use relative imports if you can
  • avoid from-import-as
  • do not hack __init__.py

Bad example

import requests, ast
from xml import *
from json import dump
from spam import eggs  # current package
from os import path as os_path
X = 1

Good example

import ast
import json
import os.path
from xml import sax

import requests

from . import eggs


X = 1

Not covered topics

  • importlib and imp module
  • namespace packages
  • BuiltinImporter and FrozenImporter

Summary

  • you could do magic with import statement
  • import machinery is quite complicated, but also reasonable
  • follow good practices
  • don't do that at home

Thank you!

Q&A

Presentation source code: bitbucket.org/khalas/import_import_presentation

reload function

  • <= Python 2.7 - reload (builtin function)
  • <= Python 3.3 - imp.reload
  • >= Python 3.4 - importlib.reload