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

Demel, Jeff Jeff.Demel at JavelinDirect.com
Thu Oct 19 12:30:24 EDT 2006


John Salerno wrote:
>'m not steeped enough in daily programming to argue that it 
>sn't necessary, but my question is why do you need to 
>reverse strings? Is it something that happens often enough 
>to warrant a method for it?

I've been programming professionally for over 10 years, and have never
once needed to reverse a string.  Maybe it's a lack of imagination on my
part, but I can't think of a single instance this might be necessary.

However, if I did ever run across this need while using Python, it would
seem awkward to use [::-1], just from a clarity standpoint.  A
string.reverse() method would be a decent thing to have.

Just my $.02.

-Jeff

P.S.  How about a string.shuffle() method that splits the string in half
into two new strings str1 and str2, and then recompiles the string by
alternating one character from each str1 and str2 as it goes?  Like
shuffling cards.  ;)
This email is intended only for the individual or entity to which it is addressed.  This email may contain information that is privileged, confidential or otherwise protected from disclosure. Dissemination, distribution or copying of this e-mail or any attachments by anyone other than the intended recipient, or an employee or agent responsible for delivering the message to the intended recipient, is prohibited. If you are not the intended recipient of this message or the employee or agent responsible for delivery of this email to the intended recipient, please notify the sender by replying to this message and then delete it from your system.  Any use, dissemination, distribution, or reproduction of this message by unintended recipients is strictly prohibited and may be unlawful.



More information about the Python-list mailing list