confirmed¶
- pyhelpers.ops.confirmed(prompt=None, confirmation_required=True, resp=False)[source]¶
Prompt user for confirmation to proceed.
See also [OPS-C-1].
- Parameters:
prompt (str | None) – Message prompting a response (Yes/No); defaults to
None
.confirmation_required (bool) – Whether to require user confirmation to proceed; defaults to
True
.resp (bool) – Default response if no user input; defaults to
False
(No).
- Returns:
User response indicating confirmation (
True
) or denial (False
).- Return type:
bool
Examples:
>>> from pyhelpers.ops import confirmed >>> if confirmed(prompt="Testing if the function works?", resp=True): ... print("Passed.") Testing if the function works? [Yes]|No: yes Passed.