将模块和 return 变量导入 Spyder 环境
Import module and return variables to Spyder environment
我想知道是否可以导入自定义模块,例如debug_funcs.py,并且有return Spyder 环境的一些变量?
我在上面定义了几个函数,在底部我调用了我想要return环境变量的__init__()
函数。然后我在 Spyder(控制台或其他方式)中调用 import debug_funcs
。
在debug_funcs.py中:
def __init__():
out1 = something
out2 = something else
return out1, out2
out1, out2 = __init__()
我希望导入模块以节省我选择所有代码和按 F9 的时间,这样历史记录就更有用了,我希望有变量可供检查。
您可以将以下内容添加到 debug_funcs.py 以将您的变量推送到当前控制台。
from IPython import get_ipython
ipython = get_ipython()
ipython.push({'out1': out1, 'out2': out2})
我想知道是否可以导入自定义模块,例如debug_funcs.py,并且有return Spyder 环境的一些变量?
我在上面定义了几个函数,在底部我调用了我想要return环境变量的__init__()
函数。然后我在 Spyder(控制台或其他方式)中调用 import debug_funcs
。
在debug_funcs.py中:
def __init__():
out1 = something
out2 = something else
return out1, out2
out1, out2 = __init__()
我希望导入模块以节省我选择所有代码和按 F9 的时间,这样历史记录就更有用了,我希望有变量可供检查。
您可以将以下内容添加到 debug_funcs.py 以将您的变量推送到当前控制台。
from IPython import get_ipython
ipython = get_ipython()
ipython.push({'out1': out1, 'out2': out2})