New (?) suggestion re: 'while x = f(): ...'

Duncan Booth duncan at NOSPAMrcp.co.uk
Thu May 30 04:19:22 EDT 2002


Jeff Epler <jepler at unpythonic.net> wrote in 
news:mailman.1022680666.24622.python-list at python.org:

>> 'H' is spelled 'iter' and already exists.
> 
> Not quite -- H will stop on "any false value", while iter(f, "") will
> stop on a single value.

I think this is similar to the difference between except with a specific 
exception, and except to catch any exception. The normal case should be to 
know what the termination condition is. (Explicit is better than implicit.)

-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?



More information about the Python-list mailing list