Steven D'Aprano <[email protected]> added the comment:
I strongly oppose this change. Merely printing an object should not have a
side-effect of this magnitude. Standard Python behaviour is that an object's
repr should return a useful string, not exit the interpreter.
This is a backwards-incompatible change: right now, it is perfectly safe to
print the builtins namespace in the interactive interpreter:
vars(builtins)
Doing so gives you are rather large dict, but it is safe and useful. If we make
exit actually exit the interpreter instead of print a human readable string,
printing the builtins will no longer be safe. It will surprisingly exit in the
middle of printing the dict.
`exit` is not magic syntax, it is an actual object. It exists in the builtins
namespace. We can put it in lists, we can introspect it and treat it like any
other object.
And most importantly, we can print it and get a useful string.
It is not user-friendly to introduce magical special cases. To call a function,
Python always requires parentheses. In the builtins and stdlib there are no
special cases of functions that magically perform some task just by trying to
view it in the interactive interpreter.
(Of course third party code can do anything. If somebody wants the `+` operator
to exit the interpreter, or len(obj) to erase their hard drive, Python will
allow it.)
Making a handful of objects -- help, exit (quit), license -- behave differently
to everything else is not user friendly. Consistency is more important than
convenience, especially when it comes to something like exit where the
side-effect is to exit the interpreter.
What of copyright and credits? I think their design is a mistake, especially
copyright. With 11 lines of output, the copyright object seriously uglifies
printing the builtins. But at least it doesn't exit the interpreter.
----------
nosy: +steven.daprano
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue44603>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com