如何查看Python的__builtins__源代码? [英] How can I see Python's __builtins__ source code?

查看:251
本文介绍了如何查看Python的__builtins__源代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以让python直接打印 __ builtins __ 的源代码吗?

Can I get python to print the source code for __builtins__ directly?

OR(或更可取的是):

OR (more preferably):

__ builtins __ ?

我至少知道以下几点:


  • __ builtins __ 是一个模块,通过键入 type(__ builtins __)

  • __builtins__ is a module, by typing type(__builtins__).

我已经尝试过针对此类SO问题的更一般情况的最佳答案建议:查找内置Python函数的源代码吗? 。但是没有运气:

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?". But no luck:


  • print inspect.getdoc(__ builtins __)

inspect.getfile(__ builtins __)给我一个描述: TypeError:<模块'__builtin __'(内置)>是内置模块

https://hg.python.org/cpython/file/c6880edaf6f3/# 似乎不包含 __ builtins __ 。我尝试过 site:搜索并浏览了几个目录,但在几个目录之后放弃了。

https://hg.python.org/cpython/file/c6880edaf6f3/# does not seem to contain an entry for __builtins__. I've tried "site:" search and browsed several of the directories but gave up after a few.

推荐答案

__ builtin __ 模块在 Python / bltinmodule.c ,这是一个非常不寻常的模块的一个非常不寻常的位置。

The __builtin__ module is implemented in Python/bltinmodule.c, a rather unusual location for a rather unusual module.

这篇关于如何查看Python的__builtins__源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆