迷茫2017-04-18 09:41:16
Code on mobile phone.
This code cleverly uses another form of iter:
If two parameters are passed to iter: callable and sentinel, the returned generator will repeatedly call callable and yield its return value until the return value and sentinel are equal.
Equivalent code:
def iter(callable, sentinel):
while True:
val = callable()
if val == sentinel: break
yield val