create lowercase strings in lists - was: (No subject)

Steven Bethard steven.bethard at gmail.com
Fri Dec 17 04:49:09 EST 2004


Mark Devine wrote:
> the trouble is it throws up the following error for set:
> 
> $ ./test.py
> Traceback (most recent call last):
>   File "./test.py", line 23, in ?
>     reflist = [normalize(element) for element in list1]
>   File "./test.py", line 20, in normalize
>     return set(text.split())
> NameError: global name 'set' is not defined
> 

The set type became a builtin in Python 2.4.  I would suggest upgrading, 
but if this is not an option, you can put this at the top of the file, 
and it should get rid of the NameError:

from sets import Set as set

Steve



More information about the Python-list mailing list