python - Call a function until a sentinel value 代码解读?
PHPz
PHPz 2017-04-18 09:39:16
0
1
455
PHPz
PHPz

学习是最好的投资!

reply all(1)
迷茫

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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template