471,350 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

Python submodules and name imports

Hi,

First take a look at:

http://www.network-theory.co.uk/docs.../Packages.html

as I will use this module file layout as an example.

If I want to do the following:

from Sound import Effects
....
Effects.echo.echofilte(bla bla)

What will Sound/Effects/__init__.py need to contain then? I tried to define
the __all__ = ['echo','surround','reverse'] parameter in the init file, but
this only seems to be effective for " .. import *" statements.

Is the correct way of accomplishing this to explicitly import the submodules
in sound/Effects/__init__.py? I'm looking for the "official" way of doing
this.

Thank you,
Frank Aune
Aug 23 '07 #1
1 1433
On Aug 23, 2:58 pm, Frank Aune <Frank.A...@broadpark.nowrote:
Hi,

First take a look at:

http://www.network-theory.co.uk/docs.../Packages.html

as I will use this module file layout as an example.

If I want to do the following:

from Sound import Effects
...
Effects.echo.echofilte(bla bla)

What will Sound/Effects/__init__.py need to contain then? I tried to define
the __all__ = ['echo','surround','reverse'] parameter in the init file, but
this only seems to be effective for " .. import *" statements.

Is the correct way of accomplishing this to explicitly import the submodules
in sound/Effects/__init__.py? I'm looking for the "official" way of doing
this.

Thank you,
Frank Aune
You can put 'import echo' into sound/Effects/__init__.py. This is a
widespread practice. You could also put 'from echo import *' into the
file, if you wanted to have a single namespace for all methods in
Effects.

Aug 23 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.