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

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

  1. Tim Chase

    Tim Chase Guest

    > 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
    egress to your soggy dead-tree satchel, you could also provide
    similar "write a binary search" or "write your own linked-list
    implementation" escape hatches... :)

    -tkc
    Tim Chase, Oct 19, 2006
    #1
    1. Advertising

  2. Tim Chase

    rick Guest

    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
    #2
    1. Advertising

  3. 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
    print "badabom!"

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


    thank you.

    </F>
    Fredrik Lundh, Oct 19, 2006
    #3
  4. Tim Chase

    Simon Forman Guest

    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
    about this: foo[-1::-2] or this: foo[-2::-2]?

    See, it's not about "blindly memorizing this stuff", it's about clever
    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
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dogbite
    Replies:
    4
    Views:
    673
    osmium
    Oct 10, 2003
  2. rtilley

    invert the order of a string

    rtilley, Feb 13, 2006, in forum: Python
    Replies:
    10
    Views:
    9,720
    Bruno Desthuilliers
    Feb 14, 2006
  3. rick
    Replies:
    42
    Views:
    2,059
    DaveM
    Oct 24, 2006
  4. Demel, Jeff
    Replies:
    7
    Views:
    263
    Carl Banks
    Oct 20, 2006
  5. Demel, Jeff
    Replies:
    3
    Views:
    272
    Duncan Booth
    Oct 20, 2006
Loading...

Share This Page