问题描述
考虑以下代码:
# import a class from another module within package
from .continuous import Continuous
from typing include List,Dict
def build_two_compartment_models(model_descriptions: Dict) -> List:
print(model_descriptions)
我在 build_two_compartment_models
中设置了一个断点,并惊讶地看到当我运行 Continuous
时列出了 locals()
类。我认为 locals()
只会包含 model_descriptions
(可能还有 Dict
和 List
)。相反,它包括:
'credits': Thanks to CWI,CNRI,BeOpen.com,Zope Corporation and a cast of thousands
for supporting Python development. See www.python.org for more information.,'license': Type license() to see the full license text,'help': Type help() for interactive help,or help(object) for help about object.,'__pybind11_internals_v3_clang_libcpp_cxxabi1002__': <capsule object NULL at 0x1194d12d0>,'__IPYTHON__': True,'display': <function IPython.core.display.display(*objs,include=None,exclude=None,Metadata=None,transient=None,display_id=None,**kwargs)>,'interpreter': <_pydev_bundle.pydev_ipython_code_executor.CodeExecutor at 0x128d6d430>,'get_ipython': <bound method InteractiveShell.get_ipython of <_pydev_bundle.pydev_ipython_console_011.PyDevTerminalInteractiveShell object at 0x128d6d8e0>>},'Dict': typing.Dict,'List': typing.List,'Continuous': diffusion.models.two_compartment.continuous.Continuous,'build_two_compartment_models': <function diffusion.models.two_compartment.build_models.build_two_compartment_models(model_descriptions: Dict) -> List>,'_pydev_stop_at_break': <function _pydevd_frame_eval.pydevd_frame_tracing._pydev_stop_at_break(line)>,'model_descriptions': {'prms': None},'__builtin__': <module 'builtins' (built-in)>,'_ih': ['','locals()'],'_oh': {},'_dh': ['/Users/xxx/PycharmProjects/diffusion_study'],'In': ['','Out': {},'get_ipython': <bound method InteractiveShell.get_ipython of <_pydev_bundle.pydev_ipython_console_011.PyDevTerminalInteractiveShell object at 0x128d6d8e0>>,'exit': <IPython.core.autocall.ExitAutocall at 0x128d6de20>,'quit': <IPython.core.autocall.ExitAutocall at 0x128d6de20>,'_': '','__': '',
为什么会在这里?尤其是 Continuous
,它是在函数外显式导入的。我对局部变量有什么不了解?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)