1 2 3 4
from itertools import groupby import doctest ...
Python On Count word occurrences in a...
by Leif Ryge,
October 31, 2008 20:37
1 2 3 4
def mk_index(seq): """Index a sequence >>> sorted(mk_index("abcba").items()) ...
Python On Count word occurrences in a...
by Leif Ryge,
October 31, 2008 19:58
This prints not only the co...
Python On Computing permutations with...
by Leif Ryge,
October 31, 2008 06:55
Answering my own question: ...
1 2 3
idiom_A = lambda x,y,z: (x and [y] or [z])[0] idiom_B = lambda x,y,z: (z, y)[x] idiom_C = lambda x,y,z: y if x else z # introduced in Python 2.5
Python On Computing permutations with...
by Leif Ryge,
October 30, 2008 20:23
Thanks! I was actually unaw...
1 2 3 4
#!/usr/bin/python2.5 def permute(li): """Generate all permutations of a sequence ...
Python Computing permutations with...
by Leif Ryge,
October 22, 2008 04:16,
5 refactorings, tagged with generator, permutations, permutate, recursion
I suspect there is a better...

Here is a version which use...