Promoting Python

Terry Reedy tjreedy at udel.edu
Wed Apr 6 15:52:28 EDT 2016


On 4/6/2016 10:14 AM, Marko Rauhamaa wrote:

> Seriously, Python wouldn't be, couldn't be Turing-complete without
> "while" (mainly because it doesn't support tail-recursion elimination).
>
> Now, if Python had an unlimited range() iterator/iterable, you could use
> a "for" statement to emulate "while".

For practical purposes, this equals 'while True: pass'

for i in itertools.count: pass

This is equivalent, regardless of memory.

class whiletrue:
     def __iter__(self): return self
     def __next__(self): return None

for none in whiletrue(): pass


-- 
Terry Jan Reedy




More information about the Python-list mailing list