[Python-Dev] A cute new way to get an infinite loop

Raymond Hettinger python at rcn.com
Thu Sep 23 17:33:00 CEST 2004


> >>> x = [1]
> >>> x.extend(-y for y in x)

In comparison, the classic form doesn't seem as magical:

    x = [1]
    for y in x:
        x.append(-y)



Raymond



More information about the Python-Dev mailing list