bundles / astropy 7.0.1 / astropy / utils / misc / did_you_mean
function
astropy.utils.misc:did_you_mean
source: /astropy/utils/misc.py :424
Signature
def did_you_mean ( s , candidates , n = 3 , cutoff = 0.8 , fix = None ) Summary
When a string isn't found in a set of candidates, we can be nice to provide a list of alternatives in the exception. This convenience function helps to format that part of the exception.
Parameters
s: strcandidates: sequence of str or dict of str keysn: intThe maximum number of results to include. See difflib.get_close_matches.
cutoff: floatIn the range [0, 1]. Possibilities that don't score at least that similar to word are ignored. See difflib.get_close_matches.
fix: callableA callable to modify the results after matching. It should take a single string and return a sequence of strings containing the fixed matches.
Returns
message: strReturns the string "Did you mean X, Y, or Z?", or the empty string if no alternatives were found.
Aliases
-
astropy.utils.misc.did_you_mean