python newb has problem with import statements

Peter Otten __peter__ at web.de
Sun Mar 19 11:12:27 CET 2006


danielmcbrearty at gmail.com wrote:

> the init file looks like this:
> 
> (docs and comments skipped)
> 
> print "in pymedia"  # added by me to see
> __all__= [ 'muxer', 'audio', 'video', 'removable' ]
> import muxer, audio, video, removable
> 
> but I can't import submodules of pymedia:

The file with the contents given above is clearly not the one that is
imported here,

> >>> import pymedia
> >>> dir(pymedia)
> ['__builtins__', '__doc__', '__file__', '__name__']

as __all__, muxer, audio etc. are missing. 

Maybe you have created a test script 'pymedia.py' in the working directory?
You can check what file you are dealing with by entering

>>> pymedia.__file__ 

If that is 'whatever/site-packages/pymedia/__init__.pyc' I'm guessing wrong.
Otherwise removing that file (probably 'pymedia.pyc') and the corresponding
source (pymedia.py) should fix your problem.

Peter



More information about the Python-list mailing list