Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Standard ways to get union, intersection, difference of lists?

Reply
Thread Tools

Re: Standard ways to get union, intersection, difference of lists?

 
 
=?ISO-8859-1?Q?Mickel_Gr=F6nroos?=
Guest
Posts: n/a
 
      06-26-2003
Thanks Gerrit, Eric and Paul, the sets module is exactly what I need!
I'm still running Python 2.2.2 though, so I will need to upgrade.

/Mickel
--
Mickel Grönroos, application specialist, linguistics, Research support, CSC
PL 405 (Tekniikantie 15 a D), 02101 Espoo, Finland, phone +358-9-4572237
CSC is the Finnish IT center for science, www.csc.fi


 
Reply With Quote
 
 
 
 
Steve Holden
Guest
Posts: n/a
 
      06-26-2003
"Mickel Grönroos" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
Thanks Gerrit, Eric and Paul, the sets module is exactly what I need!
I'm still running Python 2.2.2 though, so I will need to upgrade.


Not necessarily: I believe you can just pick up the sets module from CVS and
run it under 2.2+.

regards
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/pwp/



 
Reply With Quote
 
 
 
 
John Hunter
Guest
Posts: n/a
 
      06-26-2003
>>>>> "Steve" == Steve Holden <(E-Mail Removed)> writes:

Steve> Not necessarily: I believe you can just pick up the sets
Steve> module from CVS and run it under 2.2+.

I just tried import sets from the 2.3b1 distribution under python 2.2,
but it failed with an ImportError trying to load itertools. I believe
itertools is a C module, so perhaps it is not so straightforward to
use sets from 2.2?

John Hunter

 
Reply With Quote
 
Mike C. Fletcher
Guest
Posts: n/a
 
      06-26-2003
I've back-ported sets to 2.2.2. It was a matter of implementing a few
functions from itertools (which is a Python module IIRC). Here's the
majority of the backporting code:

### Backport to 2.2 by Mike Fletcher
from __future__ import generators
def ifilter(predicate, iterable):
if predicate is None:
def predicate(x):
return x
for x in iterable:
if predicate(x):
yield x
def ifilterfalse(predicate, iterable):
if predicate is None:
def predicate(x):
return x
for x in iterable:
if not predicate(x):
yield x
### End backport

There's some more for getting the tests to run under 2.2.2, but that's
not actually necessary to use the module.

Enjoy,
Mike

John Hunter wrote:

>>>>>>"Steve" == Steve Holden <(E-Mail Removed)> writes:
>>>>>>
>>>>>>

>
> Steve> Not necessarily: I believe you can just pick up the sets
> Steve> module from CVS and run it under 2.2+.
>
>I just tried import sets from the 2.3b1 distribution under python 2.2,
>but it failed with an ImportError trying to load itertools. I believe
>itertools is a C module, so perhaps it is not so straightforward to
>use sets from 2.2?
>
>John Hunter
>
>


_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between two ways to set Text in a TextBox ? Moe Sisko ASP .Net 0 03-31-2008 05:59 AM
what's the difference betwwen these two ways to use std::ofstream thinktwice C++ 2 08-25-2006 05:44 AM
the difference among these ways of swapping two ints storyGerald@gmail.com C++ 9 11-21-2005 12:32 PM
Re: Standard ways to get union, intersection, difference of lists? Gerrit Holl Python 0 06-26-2003 09:29 AM
Standard ways to get union, intersection, difference of lists? =?ISO-8859-1?Q?Mickel_Gr=F6nroos?= Python 2 06-26-2003 09:28 AM



Advertisments