The existing docs for errors and exceptions:

- https://docs.python.org/2/library/exceptions.html
- https://docs.python.org/3/library/exceptions.html
- https://hg.python.org/cpython/file/tip/Doc/library/exceptions.rst
- https://github.com/python/cpython/blob/master/Doc/library/exceptions.rst

- https://docs.python.org/2/tutorial/errors.html
- https://docs.python.org/3/tutorial/errors.html
- https://hg.python.org/cpython/file/tip/Doc/tutorial/errors.rst
- https://github.com/python/cpython/blob/master/Doc/tutorial/errors.rst

- https://www.tutorialspoint.com/python/python_exceptions.htm

- If the docs don't answer the question (and match to the search terms),
they probably should.

- [ ] DOC: something about why "except Exception: pass" is usually bad
- [ ] DOC: something about SystemExit and atexit:
https://docs.python.org/2/library/atexit.html


You can get alot more traceback from pytest (w/ pytest-sugar) and/or nose
(with nose-progressive).

There is extra information in the stack at exception time; but, IIUC, it
would take a number of subclasses with class-specific docs and/or class
introspection to be as detailed as "you probably wanted .append there
because this is a List and the length is n but the key was".

Maybe a "learning mode" which automatically calls inspect.getdoc() on
Exception would be useful (sys.excepthook)?
Practically, I usually just open an extra IPython shell and run
`list.append?` for docs or `list.append??` for (Python but not C!) source
(inspect.getsource).
IPython also prints the function signature with `?`

The pdb++ debugger requires funcsigs in order to print function signatures.
If pdb++ is installed, it preempts the standard pdb module; so `nosetests
--pdb` and `pytest --pdb` launch pdb++ when an error or exception is raised.

https://pypi.python.org/pypi/pdbpp/

http://nose.readthedocs.io/en/latest/plugins/debug.html

http://doc.pytest.org/en/latest/usage.html

https://docs.python.org/2/library/inspect.html

Exceptions could be better someday. Testing (and debugging) skills are
always good to learn; coincidentally, there are many great tools for it.

... https://westurner.org/wiki/awesome-python-testing#debugging

On Tuesday, November 29, 2016, Victor Stinner <victor.stin...@gmail.com>
wrote:

> Hi,
>
> Python is optimized for performance. Formatting an error message has a
> cost on performances.
>
> I suggest you to teach your student to use the REPL and use a custom
> exception handler: sys.excepthook:
> https://docs.python.org/2/library/sys.html#sys.excepthook
>
> Using a custom exception handler, you can run expensive functions,
> like the feature: "suggest len when length is used".
>
> The problem is then when students have to use a Python without the
> custom exception handler.
>
> Victor
> _______________________________________________
> Python-ideas mailing list
> Python-ideas@python.org <javascript:;>
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to