backport of 'set' to python 2.3?

Daniel Fetchinson fetchinson at googlemail.com
Wed May 21 22:02:45 EDT 2008


>> Does anyone have a pure python implementation of the builtin 'set'
>> object so that I could use that in python 2.3?
>
> Yes. You have one in Python 2.3 already
> <URL:http://www.python.org/doc/2.3.5/lib/module-sets.html>, it's just
> not a builtin.
>
>> If this would be the case that would be really great as I wouldn't
>> have to change my code that runs happily on 2.5
>
> You will, but it's as simple as:
>
>     try:
>         set()
>     except NameError:
>         from sets import Set as set
>
> You then know that 'set' refers to the set type from that point on (or
> you're not on a version of Python that has a 'set' type at all).

Thanks Ben! I should have checked the docs........

Cheers,
Daniel
-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown



More information about the Python-list mailing list