[Python-bugs-list] [ python-Feature Requests-494240 ] str.reverse
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 17 Dec 2001 20:22:31 -0800
Feature Requests item #494240, was opened at 2001-12-17 08:50
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=355470&aid=494240&group_id=5470
Category: Python Library
Group: None
Status: Open
Priority: 5
Submitted By: Allan Crooks (amc1)
Assigned to: Nobody/Anonymous (nobody)
Summary: str.reverse
Initial Comment:
The str type should *really* have a reverse
method. "How do I reverse a string?" crops up too
often on tutor lists, and there should be a neater way
to do it other than converting it to a list, reversing
it, and then joining it...
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-12-17 20:22
Message:
Logged In: YES
user_id=6380
Write a PEP. :-)
----------------------------------------------------------------------
Comment By: Allan Crooks (amc1)
Date: 2001-12-17 20:17
Message:
Logged In: YES
user_id=39733
> Show me one real-life application of reversing a string.
Ummm.... easy way to check for palindromes?
> This comes from textbook exercises IMO,
> and doesn't occur in real life.
It may not occur in many serious applications, but there
have been occasions where I've simply wanted to reverse a
string just for the fun of it really (or just to check
quickly what something is backwards).
> Adding the method would reduce the
> utility of the textbook exercise...
Not unless you explicitly said not to use str.reverse...
You could argue that doing l = list('something'); l.reverse
(); ''.join(l) perhaps is still a bit too easy for a text
book. Something more appropriate like for loops and ranges
would be suitable for an exercise.
I dunno, it just seems like it's the sort of method that
should be part of str, and it doesn't seem like the method
would be that huge or problematic to implement...
If that doesn't convince you, then at least say you'll
implement it if I figure out a worthwhile use for it. :))
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2001-12-17 08:57
Message:
Logged In: YES
user_id=6380
Show me one real-life application of reversing a string.
This comes from textbook exercises IMO, and doesn't occur in
real life. Adding the method would reduce the utility of the
textbook exercise...
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=355470&aid=494240&group_id=5470