Search code examples
pythonbuilt-in

Is there a way to modify or create a new builtin?


As a little experiment I'm trying to add a builtin into python, which could be done via auto importing with a pre processor or something. I don't know, whats the best way to go around this?

**EDIT: ** Thank you @wjandrea for telling me I would have to recompile python to acomplish my 'little experiment' lol. Fixed Gramar and Made Question clearer


Solution

  • To add a builtin, you'd need to recompile Python.

    As the Zen of Python says, "Explicit is better than implicit". So the recommended route is just to import the module/function wherever you need it. To make that simpler when writing scripts, you could add a snippet in your IDE/code editor.