On Fri, Dec 16, 2011 at 12:11 AM, Ian Kelly wrote:
> On Thu, Dec 15, 2011 at 11:30 PM, Alec Taylor wrote:
>> Just for fun, use the Hungarian Algorithm
>>
>> (Python implementation: http://software.clapper.org/munkres/)
>
> That's a pretty silly approach, but okay:
>
> def listequals(a, b):
> i
On Thu, Dec 15, 2011 at 11:30 PM, Alec Taylor wrote:
> Just for fun, use the Hungarian Algorithm
>
> (Python implementation: http://software.clapper.org/munkres/)
That's a pretty silly approach, but okay:
def listequals(a, b):
if len(a) != len(b):
return False
matrix = [[int(item
Just for fun, use the Hungarian Algorithm
(Python implementation: http://software.clapper.org/munkres/)
On Fri, Dec 16, 2011 at 3:36 AM, noydb wrote:
> I want to test for equality between two lists. For example, if I have
> two lists that are equal in content but not in order, I want a return
>
On 12/15/2011 12:59 PM, Miki Tebeka wrote:
My sort issue... as in this doesn't work
if x.sort == y.sort:
You're missing the () to make it a function call.
Also list.sort() returns none, it mutates the original list.
You can either
sorted(x) == sorted(y)
or
set(x) == set(y)
or x.sort
On Thu, Dec 15, 2011 at 11:07 AM, noydb wrote:
> Ahh, I see (on the sort issue), thanks All!
>
> Still, any other slicker ways to do this? Just for learning.
MRAB's collections.Counter suggestion is what I would do. Very tidy,
and also more efficient I think: O(n) instead of O(n log n).
--
htt
> > set(x) == set(y)
>
> Duplicates cause issues in the set() version:
You're right, I stand corrected.
--
http://mail.python.org/mailman/listinfo/python-list
On 12/15/11 11:59, Miki Tebeka wrote:
My sort issue... as in this doesn't work
if x.sort == y.sort:
You're missing the () to make it a function call.
Also list.sort() returns none, it mutates the original list.
You can either
sorted(x) == sorted(y)
or
set(x) == set(y)
Duplicates cau
On 15/12/2011 17:59, Miki Tebeka wrote:
My sort issue... as in this doesn't work
>>> if x.sort == y.sort:
You're missing the () to make it a function call.
Also list.sort() returns none, it mutates the original list.
You can either
sorted(x) == sorted(y)
or
set(x) == set(y)
But do
On 15/12/2011 17:49, noydb wrote:
On Dec 15, 11:36 am, noydb wrote:
I want to test for equality between two lists. For example, if I have
two lists that are equal in content but not in order, I want a return
of 'equal' -- dont care if they are not in the same order. In order
to get that e
On Dec 15, 11:59 am, Miki Tebeka wrote:
> > My sort issue... as in this doesn't work
> > >>> if x.sort == y.sort:
>
> You're missing the () to make it a function call.
> Also list.sort() returns none, it mutates the original list.
> You can either
> sorted(x) == sorted(y)
> or
> set(x) ==
Ahh, I see (on the sort issue), thanks All!
Still, any other slicker ways to do this? Just for learning.
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Dec 15, 2011 at 9:57 AM, John Gordon wrote:
> In <61edc02c-4f86-45ef-82a1-61c701300...@t38g2000yqe.googlegroups.com>
> noydb writes:
>
> > My sort issue... as in this doesn't work
> > >>> if x.sort =3D=3D y.sort:
> > ... print 'equal'
> > ... else:
> > ... print 'not equal'
> > ...
>
> My sort issue... as in this doesn't work
> >>> if x.sort == y.sort:
You're missing the () to make it a function call.
Also list.sort() returns none, it mutates the original list.
You can either
sorted(x) == sorted(y)
or
set(x) == set(y)
--
http://mail.python.org/mailman/listinfo/python-l
noydb, 15.12.2011 18:49:
On Dec 15, 11:36 am, noydb wrote:
I want to test for equality between two lists. For example, if I have
two lists that are equal in content but not in order, I want a return
of 'equal' -- dont care if they are not in the same order. In order
to get that equality, would
In <61edc02c-4f86-45ef-82a1-61c701300...@t38g2000yqe.googlegroups.com> noydb
writes:
> My sort issue... as in this doesn't work
> >>> if x.sort =3D=3D y.sort:
> ... print 'equal'
> ... else:
> ... print 'not equal'
> ...
> not equal
> ???
Use x.sort() instead of x.sort .
--
John Gordon
On 15/12/2011 16:36, noydb wrote:
I want to test for equality between two lists. For example, if I have
two lists that are equal in content but not in order, I want a return
of 'equal' -- dont care if they are not in the same order. In order
to get that equality, would I have to sort both lists
On Dec 15, 11:36 am, noydb wrote:
> I want to test for equality between two lists. For example, if I have
> two lists that are equal in content but not in order, I want a return
> of 'equal' -- dont care if they are not in the same order. In order
> to get that equality, would I have to sort bot
I want to test for equality between two lists. For example, if I have
two lists that are equal in content but not in order, I want a return
of 'equal' -- dont care if they are not in the same order. In order
to get that equality, would I have to sort both lists regardless? if
yes, how (having is
18 matches
Mail list logo