Question on lists

Christopher T King squirrel at WPI.EDU
Thu Jul 29 17:00:14 CEST 2004

On Thu, 29 Jul 2004, Alan G Isaac wrote:

> Newbie question:
> OK, this is great.  But I was not aware of this module,
> and I was working in my own
> So how do I handle this namespace issue?
> I.e., how can I 'import sets' and get the Python module,
> when my own script is named

The best way, of course, is to rename your script ;) it's never a good 
idea to give a script the same name as that of a module you plan to use.

If you absolutely must leave your script named, you can use the 
following trick to get to Python's

 import sys
 import sets

This removes the current directory from Python's search path.  Note you 
won't be able to access any modules in the current directory after that 
line, unless you do a "sys.path.insert(0,'')" first.

More information about the Python-list mailing list