
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

Hi! Try to type 'exit' or 'quit' in the interactive shell and you see its purpose. Pretty clever. Cheers, Rodrigo On Thu, 26 Aug 2004 14:00:40 +0200, Oliver Walczak <oliver.walczak@momatec.de> wrote:
Dear list, ...
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

On Thu, 26 Aug 2004 09:07:02 -0300, Rodrigo B. de Oliveira <rodrigobamboo@gmail.com> wrote:
Hi!
Try to type 'exit' or 'quit' in the interactive shell and you see its purpose. Pretty clever.
Yes, it's the string that tells you the proper way to exit the interpreter. But does this really belong in __builtins__? Wouldn't it be better for the interactive interpreter to register it as a global when it sets up, as it only makes sense in the context of the interactive interpreter? Not that it's a big deal :)
participants (3)
-
Andrew Durdin
-
Oliver Walczak
-
Rodrigo B. de Oliveira