backport of 'set' to python 2.3?

D

Daniel Fetchinson

Does anyone have a pure python implementation of the builtin 'set'
object so that I could use that in python 2.3? 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 and makes use of 'set'. Speed and performance
doesn't matter, any implementation that does exactly the same as the
builtin 'set' in 2.5 would be great.

Cheers,
Daniel
 
D

Daniel Fetchinson

Does anyone have a pure python implementation of the builtin 'set'
Yes. You have one in Python 2.3 already


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top