New submission from Ralph Corderoy <ralph-pythonb...@inputplus.co.uk>:
A friend wrote "exit(0)" in a script without an import of sys. I pointed out the error and he said "But it works". He was right. $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 9.10 Release: 9.10 Codename: karmic $ python --version Python 2.6.4 $ python -c 'quit("foo")' foo $ echo $? 1 $ python -Sc 'quit("foo")' Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'quit' is not defined $ python -c 'print quit.__class__, exit.__class__' <class 'site.Quitter'> <class 'site.Quitter'> $ site.py is polluting, to my mind, the builtin namespace with `exit' and `quit'. Surely this should only happen for interactive use of python? http://docs.python.org/library/constants.html#exit says "They are useful for the interactive interpreter shell and should not be used in programs." but it seems to easy for exit, especially, to be used by mistake. Could the pollution only happen if the Python interpreter is an interactive one? Or, not as good, when called, could they tell this isn't an interactive session and error? ---------- components: Library (Lib) messages: 101635 nosy: ralph.corderoy severity: normal status: open title: site.py's Quitter pollutes builtins with exit and quit for non-interactive use type: behavior versions: Python 2.5, Python 2.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue8220> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com