File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -501,17 +501,21 @@ def ask_choice(
501501) -> Any :
502502 """Ask the user to choose from a list of choices.
503503
504- :return: the selected choice
505-
506- ``func_desc`` will be called on every list item for displaying
507- and sorting the list. If not given, will default to
508- the identity function.
509-
510504 Will loop until:
511505 * the user enters a valid index
512506 * or leaves the prompt empty
513507
514- In the last case, None will be returned
508+ In the last case, `None` will be returned
509+
510+ :param prompt: a list of tokens suitable for :func:`info`
511+ :param choices: a list of arbitrary elements
512+ :func_desc: a callable. It will be used to display and
513+ sort the list of choices (unless ``sort`` is False)
514+ Defaults to the identity function.
515+ :sort: whether to sort the list of choices.
516+
517+ :return: the selected choice.
518+
515519 """
516520 if func_desc is None :
517521 func_desc = lambda x : str (x )
Original file line number Diff line number Diff line change @@ -293,6 +293,11 @@ Asking for user input
293293 >>> fruit
294294 'banana'
295295
296+
297+ .. versionchanged :: 0.10
298+
299+ Add ``sort `` paramater to disable sorting the list of choices
300+
296301 .. versionchanged :: 0.8
297302
298303 ``choices `` is now a named keyword argument
@@ -320,7 +325,6 @@ Asking for user input
320325 >>> fav_food = cli_ui.ask_password("Guilty pleasure?")
321326 :: Guilty pleasure?
322327 ****
323-
324328 >>> fav_food
325329 'chocolate'
326330
You can’t perform that action at this time.
0 commit comments