2017-09-26 51 views
1

我有一個簡單的python燒瓶項目,我需要在發生任何操作之前有一個用戶確認。如何監控python中的變量?

... 
#need to confirm from the user before the action takes place. If it is yes, continue with action(), else skip action 
#I need to keep monitoring the confirm_var here 
action() 
... 

從用戶獲得確認後,我打電話這種confirmation()功能設置使用AJAX調用confirm_var。

def confirmation() 
    #set confirm_var to yes/no depending on user input. 

所以,我的問題是如何繼續監測confirm_var

回答

0

你可以用自己的事件寫一個等待函數。等待更多的CPU餓了,但它更響應。例如,請參見here。但它取決於你的python版本。