[英]How can I see Python's __builtins__ source code?
Can I get python to print the source code for __builtins__
directly? 我可以获取python直接打印
__builtins__
的源代码吗?
OR (more preferably): 或(更可取):
What is the pathname of the source code for __builtins__
? __builtins__
的源代码的路径名是什么?
I at least know the following things: 我至少知道以下几点:
__builtins__
is a module, by typing type(__builtins__)
. __builtins__
是一个模块,通过键入type(__builtins__)
。
I have tried the best-answer-suggestions to a more general case of this SO question: "Finding the source code for built-in Python functions?" 我已经对这个SO问题的更一般情况尝试了最佳答案: “是找到内置Python函数的源代码吗?” .
。 But no luck:
但是没有运气:
print inspect.getdoc(__builtins__)
just gives me a description. print inspect.getdoc(__builtins__)
只是给我一个描述。
inspect.getfile(__builtins__)
just gives me an error: TypeError: <module '__builtin__' (built-in)> is a built-in module
inspect.getfile(__builtins__)
只是给我一个错误: TypeError: <module '__builtin__' (built-in)> is a built-in module
inspect.getfile(__builtins__)
TypeError: <module '__builtin__' (built-in)> is a built-in module
https://hg.python.org/cpython/file/c6880edaf6f3/# does not seem to contain an entry for __builtins__
. https://hg.python.org/cpython/file/c6880edaf6f3/#似乎不包含
__builtins__
的条目。 I've tried "site:" search and browsed several of the directories but gave up after a few. 我已经尝试过“ site:”搜索并浏览了几个目录,但在几个目录之后放弃了。
__builtin__
模块是在Python/bltinmodule.c
,这是一个非常不寻常的模块的一个不寻常的位置。
I can't try it right now, but python default ide is able to open core modules easily (I tried with math and some more) 我现在无法尝试,但是python default ide能够轻松打开核心模块(我尝试过使用数学等方法)
https://docs.python.org/2/library/idle.html https://docs.python.org/2/library/idle.html
On menus. 在菜单上。 Open module.
打开模块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.