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!
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!
Comment