"pythonic"

Erik Max Francis max at alcyone.com
Mon Apr 21 15:13:54 EDT 2003


soporte_cali wrote:

> I am quite new to python so please forgive me if my question is too
> newby. I am running a phyton exe file, linux red hat, it is an
> indexing
> system that takes a flat file and index it. the py program once runned
> is giving  me this:
> 
>  ./index.py:57: SyntaxWarning: import * only allowed at module level
>   def createIndex(dbname,idtokenNum=1,keySize=10,idtokenChar=' '):
> error: unknown library " <nameoflibrary.py> " does not exit
> Library  nameoflibrary.py  Does not exist
> 
> so where should I place the name of this library? I mean is there any
> special place to put it? libnames? well thanks in advance..

You haven't shown us the code that generates this warning and error, so
it's very difficult to say what the resolution will be.  The first
warning is generated by something like:

	def f():
	    from someModule import *

and is simply telling you that using the "from ... import *" syntax is
only officially allowd at the toplevel of a module, e.g.:

	from someModule import *

	def f():
	    ...

(But there are lots of good reasons not to use "from ... import *" in
the first place; it decontructs the very namespaces which modules were
meant to create, and can encourage name collisions.)

As for the second error, I can't say.  My only guess from the error
would be you wrote something like:

	import <someModule.py>

when you really meant

	import someModule

(no angle brackets, no .py extension).  It may well be the very same
line where you do from ... import *.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ The revolution will not televised
\__/ Public Enemy
    Maths reference / http://www.alcyone.com/max/reference/maths/
 A mathematics reference.




More information about the Python-list mailing list