从__future__导入大括号起如何工作?

时间:2018-09-05 05:41:43

标签: python

Python中有一个关于括号的well-known joke。但是-它是如何工作的?

当我搜索源文件时,找不到关于花括号的任何内容:

$ python2.7
python2.7
Python 2.7.10 (default, Feb  7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import braces
  File "<stdin>", line 1
SyntaxError: not a chance
>>> import __future__
>>> __future__.__file__
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/__future__.pyc'
>>>
zsh: suspended  python2.7
$ grep 'braces' /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/__future__.py
[no response]

0 个答案:

没有答案