On 10/15/07, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> >>> ''.join(reversed("abc"))
> 'cba'
> >>> list(reversed(range(3)))
> [2, 1, 0]
>
> It doesn't take much to make a more user-friendly version:
>
>
> def myreversed(sequence):
>     if isinstance(sequence, basestring):
>         return type(sequence)().join(reversed(sequence))
>     else:
>         return type(sequence)(reversed(sequence))
>
> (in fact, that's so simple I wonder why the built-in reversed() doesn't
> do that).

simple:
In the face of ambiguity, refuse the temptation to guess.

:-)
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to