[EMAIL PROTECTED] wrote:
> The use of frozenset can okay when sub-sequences are longer, but for
> this problem it's slow, and anyway there are situations of repeated
> data like this that have to be considered:
Not just for frozenset; this has to be considered whatever the
representation.
>
> fr
The use of frozenset can okay when sub-sequences are longer, but for
this problem it's slow, and anyway there are situations of repeated
data like this that have to be considered:
frozenset( ('a', 'a') )
==>
frozenset(['a'])
For Py2.4 the faster and better solution seems Peter Otten one.
James St
Pierre Quentel wrote:
> Another method is to build two sets of sets, one for E1 and one for
E2,
> then make the intersection of these sets
>
> - with Python 2.3
>
> >>> E1=[('a','g'),('r','s')]
> >>> E2=[('g','a'),('r','q'),('f','h')]
> >>> from sets import Set,ImmutableSet
> >>> f=Set([Immuta
Another method is to build two sets of sets, one for E1 and one for E2,
then make the intersection of these sets
- with Python 2.3
>>> E1=[('a','g'),('r','s')]
>>> E2=[('g','a'),('r','q'),('f','h')]
>>> from sets import Set,ImmutableSet
>>> f=Set([ImmutableSet(s) for s in E1])& Set([ImmutableSet(
Learned list comprehension today, its cool:
>>> E1=[('a','g'),('r','s')]
>>> E2=[('g','a'),('r','q'),('f','h')]
>>> [x for x in E1 for y in E2 if x == y or (x[1],x[0])==y]
[('a', 'g')]
On Sunday 20 February 2005 09:24 am, [EMAIL PROTECTED] wrote:
> Hi,
> I have 2 lists of tuples that look lik
[EMAIL PROTECTED] wrote:
> Hi,
> I have 2 lists of tuples that look like:
> E1=[('a','g'),('r','s')] and
> E2=[('g','a'),('r','q'),('f','h')].
> In this tuple, the ordering does not
> matter, i.e. (u,v) is the same as (v,u).
>
> What I want to do is the following:
> given 2 list of tuples, E1 and
[EMAIL PROTECTED] wrote:
> I have 2 lists of tuples that look like:
> E1=[('a','g'),('r','s')] and
> E2=[('g','a'),('r','q'),('f','h')].
> In this tuple, the ordering does not
> matter, i.e. (u,v) is the same as (v,u).
>
> What I want to do is the following:
> given 2 list of tuples, E1 and E2, I