# Re: invert or reverse a string... warning this is a rant

Discussion in 'Python' started by Tim Chase, Oct 19, 2006.

1. ### Tim ChaseGuest

> Is this why the applicants I see that are fresh out of college
> with their shiny new computer science degrees can't seem to
> code their way out of a wet paper bag?

Well, there you go! Apparently, your wet paper bag has no
"detect a palendrome" exit. While you're installing such an
implementation" escape hatches...

-tkc

Tim Chase, Oct 19, 2006

2. ### rickGuest

Tim Chase wrote:

> Well, there you go! Apparently, your wet paper bag has no "detect a
> palendrome" exit. While you're installing such an egress to your soggy
> dead-tree satchel, you could also provide similar "write a binary

Glad you guys are enjoying this. We're getting off-topic and I think my
point is being lost to jest.

As humans, we know very little. But one of the basics of our knowledge
is order or sequence. 1,2,3,4 is natural so is 4,3,2,1 (count down to
blast off for example). When we put our shirt on inside-out or watch
someone moon walk (Micheal Jackson) it's immediately obvious and easy to
see that the sequence is reversed. Backwards is pure, simple and easy.
This is not so in Python and it should be.

That's all I have to day about that.

rick, Oct 19, 2006

3. ### Fredrik LundhGuest

rick wrote:

>> Well, there you go! Apparently, your wet paper bag has no "detect a
>> palendrome" exit. While you're installing such an egress to your soggy
>> dead-tree satchel, you could also provide similar "write a binary

>
> Glad you guys are enjoying this. We're getting off-topic and I think my
> point is being lost to jest.
>
> As humans, we know very little. But one of the basics of our knowledge
> is order or sequence. 1,2,3,4 is natural so is 4,3,2,1 (count down to
> blast off for example). When we put our shirt on inside-out or watch
> someone moon walk (Micheal Jackson) it's immediately obvious and easy to
> see that the sequence is reversed. Backwards is pure, simple and easy.
> This is not so in Python and it should be.

natural = 1, 2, 3, 4
for item in reversed(natural):
print item

> That's all I have to day about that.

thank you.

</F>

Fredrik Lundh, Oct 19, 2006
4. ### Simon FormanGuest

rick wrote:
....
> see that the sequence is reversed. Backwards is pure, simple and easy.
> This is not so in Python and it should be.

foo[::-1] isn't "pure, simple and easy"?

It derives cleanly from the slice notation, it does exactly what you
want, and it even works with lists and tuples and any other class
written to support slice notation.

Does ruby have a built in string function to do this: foo[::-2]? How

abstractions that allow you to quickly, flexibly and powerfully program
your computer. I'd rather learn a few well thought out abstractions
than memorize a set of methods.

The answer to your OP question, "Why can't Python have a reverse()
function/method like Ruby?" is "It can." You can build it yourself
quickly and easily, and a lot of other functions as well.

Peace,
~Simon

Simon Forman, Oct 20, 2006