[Tutor] reversing a string

Wesley Chun wesc@deirdre.org
Tue, 3 Jul 2001 12:12:09 -0700 (PDT)


On Tue, 3 Jul 2001, Praveen Pathiyil wrote:

>         Is there any methods in string module or any builtin functions to reverse a string ?
>  I am using Python 1.5.2

as others have pointed out, the answer is no, but the
easiest way to do it in Python is to reverse a list.

however, if your application requires reverse a massive
number of strings continuously, it would probably benefit
you to write such functionality as an extension.  that
way, you won't have a "translation" bottleneck.

and as it turns out, this is the extension example in
Chapter 20 (Extending Python) in the Core Python Programming
text.  (shamelss but relative plug i hope!)  ;-)  if you're
not interested in the book, you can still get the code from
the book's website (see below).

hope this helps!

-wesley

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Silicon Valley-SF Bay Area Python users group:  http://baypiggies.org

"Core Python Programming", Prentice Hall PTR, December 2000
    http://starship.python.net/crew/wesc/cpp/

wesley.j.chun :: wesc@baypiggies.org
cyberweb.consulting :: silicon.valley, ca
http://www.roadkill.com/~wesc/cyberweb/