PEP 322: Reverse Iteration (second revision, please comment)

Ron Adam radam2 at tampabay.rr.com
Thu Oct 30 19:59:24 EST 2003


On Thu, 30 Oct 2003 11:38:42 +0100, Werner Schiendl <ws-news at gmx.at>
wrote:

>
>even though "reverse" as a verb would be more consistent with "zip" and 
>"enumerate", it could be assumed to change the sequence passed as arg 
>(it sounds like a command)
>
>So I agree that "reversed" is the best alternative IMHO
>

First, I apologize if I'm butting in.  I'm still new to Python,  but
maybe that viewpoint is needed also.

>From looking at the PEP,  weather to use reverse or reversed should
depend on if this function can or will be used outside of  'for in'
statements.   

If it is only used within for statements,  then reversed makes since,
but maybe not as a function, but a keyword used in conjunction with
'for' or 'in'...    such as 'in reversed'.   

     for  x in reversed range(items):


If it is used in other cases outside of for loops,  then it should
probably be a function that returns a reversed list.   In that case it
should be called reverse.

    for y in reverse(range(list)):

Would be the same as:  

    x = reverse(list)
    for y in range(x)


I don't know enough  about Pythons internals to know if either
of these would cause conflicts.   So this is just my opinion on how
readable and natural it looks.


_Ronald R. Adam







More information about the Python-list mailing list