This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author SylvainDe
Recipients SylvainDe, corona10, ronaldoussoren, serhiy.storchaka, vstinner
Date 2021-01-20.19:51:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1611172281.32.0.211659579197.issue42955@roundup.psfhosted.org>
In-reply-to
Content
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)
History
Date User Action Args
2021-01-20 19:51:21SylvainDesetrecipients: + SylvainDe, ronaldoussoren, vstinner, serhiy.storchaka, corona10
2021-01-20 19:51:21SylvainDesetmessageid: <1611172281.32.0.211659579197.issue42955@roundup.psfhosted.org>
2021-01-20 19:51:21SylvainDelinkissue42955 messages
2021-01-20 19:51:20SylvainDecreate