def _not_divisible(n): return lambda x: x % n > 0

如下代码中如何理解:传入的实际参数,替换def中的x还是n?
def _not_divisible(n):
return lambda x: x % n > 0


def _odd_iter():
n = 1
while True:
n = n + 2
yield n


def _not_divisible(n):
return lambda x: x % n > 0


def primes(n):
return lambda x: x % n > 0


def primes():
yield 2
it = _odd_iter()
while True:
n = next(it)
yield n
it = filter(_not_divisible(n), it)


for n in primes():
if n < 1000:
print(n)
else:
break

转载于:https://www.cnblogs.com/LewisAAA/p/9270972.html

你可能感兴趣的:(python)