inside-out range function

William Clifford mr.william.clifford at gmail.com
Tue Apr 28 16:37:38 EDT 2009


On Apr 27, 10:50 pm, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> William Clifford <mr.william.cliff... at gmail.com> writes:
> > def enrag(start, stop=None, step=1):
> >     '''Yield a range of numbers from inside-out, evens on left.'''
>
>     >>> list(enrag(10))
>     [8, 6, 4, 2, 0, 1, 3, 5, 7, 9]    
>
> ok, but:
>
>     >>> list(enrag(10,20))
>     [18, 16, 14, 12, 10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
>
> is that really what you wanted?
>
>     >>> list(enrag(20))
>     [18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]

Uh. No. Thank you. This was an easy fix. But now I've found other
problems with stepping I was trying to get it to do too. Yuck.

--
William Clifford



More information about the Python-list mailing list