【发布时间】:2017-10-27 03:02:21
【问题描述】:
非常感谢您的帮助。具体来说,我在 pythonista 中使用 UI 模块,以及一个 .pyui 文件。
我的应用程序有两个按钮 - 一个叫做“编译”,另一个叫做“执行”。
编译:
# First Button
def compile(sender):
*creates a list by calling another function*
*let's say this is called "myList"*
执行:
# Second button that pulls a random element from the list
def execute(sender):
random.choice(myList)
但是,当我在按钮 1 中创建 myList(并且工作正常)时,我似乎无法在按钮 2 中调用它,因为它们是两个独立的实例。
因此,有没有办法以某种方式使列表成为“全球性”?这里最好和最 Pythonic 的解决方案是什么?
【问题讨论】:
标签: python ios list user-interface pythonista