Import w/ '.' syntax

Jeff McNeil jeff at jmcneil.net
Fri May 15 17:20:17 CEST 2009


On May 15, 10:50 am, mrstevegross <mrstevegr... at gmail.com> wrote:
> Remind me: is it possible to craft an import statement like this:
>   import foo.bar
>
> If so, what's going on here exactly? Is Python looking for a module
> called 'bar', in a directory called 'foo', in a search path somewhere?
> Or am I totally misunderstanding the import semantics.
>
> Thanks,
> --Steve

In that specific case, you're looking for a module 'bar' in the 'foo'
package, which should be located somewhere on sys.path.

http://docs.python.org/tutorial/modules.html

That covers it pretty well.

Thanks,

Jeff
mcjeff.blogspot.com



More information about the Python-list mailing list