我正在编写一个 sublime editor 2 插件,并希望它在会话期间记住一个变量。我不希望它将变量保存为文件(它是密码),但希望能够重复运行命令,并且变量可以访问。
我希望我的插件能够像这样工作......
import commands, subprocess
class MyCommand(sublime_plugin.TextCommand):
def run(self, edit, command = "ls"):
try:
thevariable
except NameError:
# should run the first time only
thevariable = "A VALUE"
else:
# should run subsequent times
print thevariable