fast way to filter a set?
Nicola Mingotti
nicola-mingotti at libero.it
Wed Sep 17 12:51:59 EDT 2003
fortepianissimo at yahoo.com.tw (Fortepianissimo) writes:
> I know I can do things like
>
> s=Set(range(1,11))
> s=Set(filter(lambda x:x%2==0,s))
>
> But this seems a bit slow since filter returns a list which then must
> be converted back to a set. Any tips? Thanks!
Can you ?
I tried python2.3 and 2.2 and it replies
: "NameError: name 'Set' is not defined" .
There is a PEP but it seems it's steel 'under consideration'.
http://www.python.org/peps/pep-0218.html
May be , if this proposal is accepted you
one day could write :
{ x for x in S if x%2 == 0 } # S be a set .
bye.
More information about the Python-list
mailing list