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

rick ath-admin at vt.edu
Thu Oct 19 11:47:38 EDT 2006


Why can't Python have a reverse() function/method like Ruby?

Python:
x = 'a_string'
# Reverse the string
print x[::-1]

Ruby:
x = 'a_string'
# Reverse the string
print x.reverse

The Ruby approach makes sense to me as a human being. The Python 
approach is not easy for me (as a human being) to remember. Can that be 
changed or should I just start blindly memorizing this stuff?

P.S. I like Python better than Ruby 90% of the time and use Python 90% 
of the time, but 10% of the time, little things such as this drive me crazy!



More information about the Python-list mailing list