[Biopython-dev] test_AlignIO to python 3

Peter Cock p.j.a.cock at googlemail.com
Mon Jul 5 13:18:53 UTC 2010


2010/7/5 Tiago Antão <tiagoantao at gmail.com>:
> 2010/7/5 Peter Cock <p.j.a.cock at googlemail.com>:
>> For the codon sort case, the old code effectively did two sorts
>> (one by length with a tie breaker). If you can write some unit tests
>> to check we don't alter the behaviour, the clean fix is nicer.
>
>
>>>> a=[(1,2),(1,1),(2,1),(1,0)]
>>>> a.sort(key=lambda x:(x[0],x[1]))
>>>> a
> [(1, 0), (1, 1), (1, 2), (2, 1)]
>
>
> Multi-level sorting is possible ;)
> thus
> possible.sort(key=lambda x:(len(self.ambiguous_protein[x]), x))
>

Neat - with a sensible comment to explain why, that looks good.

Peter




More information about the Biopython-dev mailing list