SylvainDe <sylvain.des...@gmail.com> added the comment:
For similar reasons as friendly-traceback, I'd be interested in a list of stdlib modules to be able to provide additional information in case of exceptions. For instance: string.ascii_lowercase > Before: NameError("name 'string' is not defined",) > After: NameError("name 'string' is not defined. Did you mean to import string > first) from maths import pi > Before: ImportError('No module named maths',) > After: ImportError("No module named maths. Did you mean 'math'?",) choice > Before: NameError("name 'choice' is not defined",) > After: NameError("name 'choice' is not defined. Did you mean 'choice' from > random (not imported)?",) from itertools import pi > Before: ImportError('cannot import name pi',) > After: ImportError("cannot import name pi. Did you mean 'from math import > pi'?",) The first 2 cases only use the module name but the last 2 cases will actually import the modules to get the names in it and I want to do this for modules which are safe to import (no side-effect expected). Source: https://github.com/SylvainDe/DidYouMean-Python/blob/master/didyoumean/didyoumean_internal.py#L30 (but if you are interested in that kind of features, I'd recommend using friendly-traceback instead) ---------- nosy: +SylvainDe _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42955> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com