Eli*_*sha 54 python python-2.7 python-internals
我想知道在命令上执行的代码究竟是什么:
>>> from __future__ import braces
SyntaxError: not a chance
Run Code Online (Sandbox Code Playgroud)
所以,因为python是开源的,我打开C:\Python27\Lib\__future__.py
并查看.令人惊讶的是,我发现没有处理导入braces
模块的东西.
所以,我的问题是,处理这个问题的代码在哪里?当我运行该命令时会发生什么?
Pet*_*vaz 65
代码在将来.c:
future_check_features(PyFutureFeatures *ff, stmt_ty s, const char *filename)
...
else if (strcmp(feature, "braces") == 0) {
PyErr_SetString(PyExc_SyntaxError,
"not a chance");
PyErr_SyntaxLocation(filename, s->lineno);
return 0;
}
Run Code Online (Sandbox Code Playgroud)