2013-03-22 80 views

回答

0

下面的代码解决了这个问题:

from __future__ import print_function #needed python 2.7 only 


import random 
example_expression = lambda: random.random() 

a = [0] 
b = [-1] 

[ print(a[0]) 
    for i in iter(int,1) #causes an infinite loop 
    if not a.__setitem__(0,example_expression()) #__setitem__ will return None 
    and a[0]>b[0] 
    and not b.__setitem__(0,a[0]) ] 
+1

你熟这一个相当快的;-P – mgilson 2013-03-22 17:44:34

+1

'example_expression()'应该是'some_expression()' – 2013-03-22 17:45:35

+0

谢谢,固定! :) – d33tah 2013-03-22 17:49:10