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

Brad rtilley at vt.edu
Thu Oct 19 12:46:50 EDT 2006


Fredrik Lundh wrote:
> rick wrote:
> 
>> The Ruby approach makes sense to me as a human being.
> 
> do the humans on your planet spend a lot of time reversing strings? it's 
> definitely not a very common thing to do over here.

On our planet, we're all dyslexic. We tend to do things 'backwards' so 
being able to easily invert what we do helps the people we show the code 
to on your planet make sense of it.

> 
> anyway, if you do this a lot, why not define a helper function?
> 
>     def reverse(s):
>         return s[::-1]
> 
>     print reverse("redael ruoy ot em ekat")

Thanks, that's what I ended up doing.



More information about the Python-list mailing list