Re:Why Python is Important for You
by evincarofautumn on Saturday February 11, 2012 @06:52PM
(#3580542)
Slice syntax in Python always bothered me. This would be slightly more readable:
''.join(reversed(string))
Except it requires you to have an idea of how iteration works (beginners don’t) and why that “join” needs to be there, and it’s still an order of magnitude slower. But hey. Ruby is prettier in some ways, Python in others, and beggars, as they say, can’t be choosers.Way way slower than the slicing.
Reverse a string in ruby: string.reverse()
Reverse a string in python: string[::-1]