Oracle Oracle - 1 year ago 60
Python Question

How can I see Python's __builtins__ source code?

Can I get python to print the source code for


OR (more preferably):

What is the pathname of the source code for

I at least know the following things:

  • __builtins__
    is a module, by typing

  • 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__)
      just gives me a description.

    • inspect.getfile(__builtins__)
      just gives me an error:
      TypeError: <module '__builtin__' (built-in)> is a built-in module

    • does not seem to contain an entry for
      . I've tried "site:" search and browsed several of the directories but gave up after a few.

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download