invert or reverse a string... warning this is a rant

James Stroud jstroud at
Thu Oct 19 20:54:22 CEST 2006

Paul Boddie wrote:
> James Stroud wrote:
> I guess Python 2.5 has the reversed method of which you speak.

Not that I could find (as methods of any built in sequence type). 2.5 
just has the "reversed" function that returns and iterator and so 2.5 
requires these kind of gymnastics on built in sequences:

> "".join(list(reversed(list(s))))

Of course, I think str.join can operate on iterators, as Paul Rubin 

 > print ''.join(reversed(x))

This latter approach still seems a little clunky, though.


James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

More information about the Python-list mailing list