[Tutor] First real script

Alan Gauld alan.gauld at btinternet.com
Mon Nov 6 23:43:03 CET 2006


"Carlos" <carloslara at web.de> wrote in message 
news:454FB2D3.60704 at web.de...

> Do you know a better way to do this?
>
>            if i < A_Len-1:
>                a = A_List[i-1]
>                b = A_List[i]
>                c = A_List[i+1]
>            else:
>                a = A_List[i-1]
>                b = A_List[i]
>                c = A_List[0]

You would think so, just by looking at it, but I must confess
I can't offhand think of anytthing significantly better. The only
way to make it more consistent would be to
1) implement a real circular list (there probably is one out there 
somewhere....)
2) always duplicate the first entry at the end of the list, then stop 
an len-2.

HTH,

Alan G. 




More information about the Tutor mailing list