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

rick ath-admin at vt.edu
Thu Oct 19 13:58:46 EDT 2006


Demel, Jeff wrote:
> Ok, let me re-phrase:
> 
> ...[snip]...
> I've been programming professionally for over 10 years, and have never
> once needed to reverse a string *or detect a palindrome*.  Maybe it's a
> lack of imagination on my part, but I can't think of a single instance
> this might be necessary.
> ...[snip]...

I read files backwards all the time. Just for the heck of it. Now, maybe 
I don't *need* to do this, but I do and I'd like to be able to do so 
like this:

x = open('file_name')
print x.read().reverse()
*OR* print reverse(x.read())
x.close()

To me, that makes sense. Of course, like I said earlier, I think backwards.



More information about the Python-list mailing list