{ } Raw JSON

bundles / astropy latest / 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 : str
candidates : sequence of str or dict of str keys
n : int

The maximum number of results to include. See difflib.get_close_matches.

cutoff : float

In the range [0, 1]. Possibilities that don't score at least that similar to word are ignored. See difflib.get_close_matches.

fix : callable

A 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 : str

Returns 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