Bill Mill wrote: > On 5/19/05, Peter Otten <[EMAIL PROTECTED]> wrote: > >>Bill Mill wrote: >> >> >>>>Traceback (most recent call last): >>>>File"<stdin>",line1,in? >>>>NameError: name 'sorted' is not defined >>>> >>>>I think you're probably using 2.4 ?? >>> >>>Yes, sorted() is new in python 2.4 .You could use a very lightly >>>tested pure-python partial replacement: >> >>By the way, sorted() can be removed from your original post. >> >>Code has no effect :-) > > > I'm gonna go ahead and disagree with you:
Me too, although I would forgo the sort altogether (while making things a little more readable IMO): > alpha = 'abcdefghijklmnopqrstuvwxyz'.upper() > pairs = [''.join((x,y)) for x in alpha for y in [''] + [z for z in alpha]] > pairs = sorted(pairs, key=len) alpha = 'abcdefghijklmnopqrstuvwxyz'.upper() pairs = [x for x in alpha] + [''.join((x,y)) for x in alpha for y in alpha] -- http://mail.python.org/mailman/listinfo/python-list