Q:

Python: list of distinct, empty sets

I am a python newbie and am attempting to write code for sieve of Eratosthenes. For this I have to initialize a list of empty sets. I tried doing this factors=[set()]*1001, but this produces a shallow copy. I want a deep copy, so that factors[i] and factors[j] point to different sets. Is there a simple syntax for doing that?

A:

factors = [set() for index in xrange(1001)]

A:

Same as always.
factors = [set() for x in range(1001)]

