def test(): print(choose(['choice a', 'choic b'])) #print(choose(['choice a', 'choic b'])) # run into error, when call this again: RuntimeError: A QApplication instance already exists.