John Goodleaf <[email protected]> writes:

> The __init__.py file marks the contents of the directory as a package. Its 
> code is executed when you reference the package.

More specifically, that code is executed in the package's namespace.
Your first `import foo` makes a new module 'foo' and does effectively
`execfile('foo/__init__.py', foo.__dict__)`. `import foo.cars` makes the
module 'foo.cars', does the equivalent execfile, assigns it to
`foo.cars`, and then imports that.

Reply via email to