Re: Fast forward-backward (write-read)

Discussion in 'Python' started by David Hutto, Oct 23, 2012.

  1. David Hutto

    David Hutto Guest

    > Don't forget to use timeit for an average OS utilization.
    >
    > I'd suggest two list comprehensions for now, until I've reviewed it some more:
    >
    > forward = ["%i = %s" % (i,chr(i)) for i in range(33,126)]
    > backward = ["%i = %s" % (i,chr(i)) for i in range(126,32,-1)]
    >
    > for var in forward:
    > print var
    >
    > for var in backward:
    > print var
    >
    > You could also use a dict, and iterate through a straight loop that
    > assigned a front and back to a dict_one = {0 : [0.100], 1 : [1.99]}
    > and the iterate through the loop, and call the first or second in the
    > dict's var list for frontwards , or backwards calls.
    >
    >
    > But there might be faster implementations, depending on other
    > function's usage of certain lower level functions.
    >


    Missed the part about it being a file. Use:

    forward = ["%i = %s" % (i,chr(i)) for i in range(33,126)]
    backward = ["%i = %s" % (i,chr(i)) for i in range(126,32,-1)]

    print forward,backward




    --
    Best Regards,
    David Hutto
    CEO: http://www.hitwebdevelopment.com
     
    David Hutto, Oct 23, 2012
    #1
    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. Virgil Stokes

    Fast forward-backward (write-read)

    Virgil Stokes, Oct 23, 2012, in forum: Python
    Replies:
    7
    Views:
    154
    Virgil Stokes
    Oct 25, 2012
  2. Tim Chase
    Replies:
    0
    Views:
    190
    Tim Chase
    Oct 23, 2012
  3. Dennis Lee Bieber

    Re: Fast forward-backward (write-read)

    Dennis Lee Bieber, Oct 23, 2012, in forum: Python
    Replies:
    0
    Views:
    145
    Dennis Lee Bieber
    Oct 23, 2012
  4. Virgil Stokes

    Re: Fast forward-backward (write-read)

    Virgil Stokes, Oct 23, 2012, in forum: Python
    Replies:
    4
    Views:
    202
    Tim Golden
    Oct 24, 2012
  5. Virgil Stokes

    Re: Fast forward-backward (write-read)

    Virgil Stokes, Oct 23, 2012, in forum: Python
    Replies:
    0
    Views:
    122
    Virgil Stokes
    Oct 23, 2012
Loading...

Share This Page