[Python-Dev] exit in __builtins__

Oliver Walczak oliver.walczak at momatec.de
Thu Aug 26 14:00:40 CEST 2004


Dear list,

as I am already quite experienced in python programming I recently started
to dive into the C-depths of the language. So it was a logical implication
to register for this newsgroup as there is no one else I can talk about
this.

So here's one thing I tried to evolve out of the sources but couldn't find
out how it works internally:

If you call dir(__builtins__) after starting a python (2.3.4) session you
get a list all well known builtin functions. I noticed, that there is
already an exit function available as builtin (NOT sys.exit!!). But when you
call exit(0) it says

TypeError: 'str' object is not callable

So I called

print __builtins__.exit.__doc__

And surprisingly I got the doc string from str. So I started browsing the
sources, and in ./Python/bltinmodule.c there get most of the builtin
functions attached to __builtin__, but not the "exit" call.

Is it a bug or a feature? exit as builtin is not documented anywhere and I
cannot find out where it gets included or attached to the str object in the
sources. Any idea?

Best regards
Oliver



More information about the Python-Dev mailing list