[Tutor] Possible to import imports?

Rob Kirkpatrick robert.d.kirkpatrick at gmail.com
Mon Jun 23 19:27:13 CEST 2008


I've googled a bit and tried some things on my own, but can't seem to
determine if it's possible to declare some standard library imports in one
package/module then import that package/module somewhere else and reap the
benefit of those initial imports.

For example, if I have a setup like this:

foo
  __init__.py
  bar
    __init__.py
    hello.py

Could I put "import datetime" in foo's __init__.py and do an import of foo
from hello.py and start using datetime in hello.py without importing
datetime specifically in hello.py?  All the examples I see import all the
necessary standard library mods in the script/module that specifically uses
them so either what I want to do is not possible or a bad idea.  Thoughts?

Cheers,
Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080623/178632ab/attachment.htm>


More information about the Tutor mailing list