I want to get the path and source code of the __builtin__
module, where can I get it?
问问题
453 次
3 回答
5
Latest (trunk) C sources of __builtin__
module: http://svn.python.org/view/python/trunk/Python/bltinmodule.c?view=markup
于 2011-02-13T02:13:39.937 回答
2
The __builtin__
module is built-in, there is no Python source for it. It's coded in C and included as part of the Python interpreter executable.
于 2011-02-13T02:06:13.947 回答
2
You can't. it is built-in to the interpreter.
>>> # os is from '/usr/lib/python2.7/os.pyc'
>>> import os
>>> os
<module 'os' from '/usr/lib/python2.7/os.pyc'>
>>> # PyQt4 is from '/usr/lib/python2.7/site-packages/PyQt4/__init__.pyc'
>>> import PyQt4
>>> PyQt4
<module 'PyQt4' from '/usr/lib/python2.7/site-packages/PyQt4/__init__.pyc'>
>>> # __builtin__ is built-in
>>> import __builtin__
>>> __builtin__
<module '__builtin__' (built-in)>
In a program, you could use the __file__
attribute, but built-in modules do not have it.
>>> os.__file__
'/usr/lib/python2.7/os.pyc'
>>> PyQt4.__file__
'/usr/lib/python2.7/site-packages/PyQt4/__init__.pyc'
>>> __builtin__.__file__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute '__file__'
于 2011-02-13T02:08:49.620 回答