Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31964
| References | <5086AA35.4000509@it.uu.se> <CA+vVgJV6feUL0gTPC==3fp3Wq8zvRXgoyhVaUYnZNtMfF8qpLw@mail.gmail.com> |
|---|---|
| Date | 2012-10-23 18:36 -0400 |
| Subject | Re: Fast forward-backward (write-read) |
| From | David Hutto <dwightdhutto@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2695.1351031796.27098.python-list@python.org> (permalink) |
> 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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Fast forward-backward (write-read) David Hutto <dwightdhutto@gmail.com> - 2012-10-23 18:36 -0400
csiph-web