which re a|l|t|e|r|n|a|t|i|v|e matched?
Skip Montanaro
skip at pobox.com
Mon Oct 27 14:37:28 EST 2003
>> pat = reduce(lambda acc, key: "%s|(%s)" % (acc, key), d.keys())[1:]
Diez> Oops, forgot the first argument for acc, its "" of course:
Diez> pat = reduce(lambda acc, key: "%s|(%s)" % (acc, key), d.keys(), "")[1:]
Don't say, "of course". I would rather stick my hand in a vise than use
reduce() so it wasn't obvious to me. ;-) Thanks for the suggestion. I
suspect Tim's .lastindex solution will be simplest.
Skip
More information about the Python-list
mailing list