本文整理汇总了Python中session.Session.clear方法的典型用法代码示例。如果您正苦于以下问题:Python Session.clear方法的具体用法?Python Session.clear怎么用?Python Session.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类session.Session
的用法示例。
在下文中一共展示了Session.clear方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: retrieve_data_point_count
# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import clear [as 别名]
def retrieve_data_point_count(session: Session) -> int:
while True:
data_point_count = get_integer_from_user(session, 'How many data points do you want to create: ')
if data_point_count <= 0:
session.get_io().output('Your input must be greater than zero, instead got {}'.format(str(data_point_count)))
time.sleep(1)
session.clear()
continue
return data_point_count
示例2: get_data_points_per_line
# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import clear [as 别名]
def get_data_points_per_line(session: Session) -> int:
while True:
data_points_per_line = get_integer_from_user(session, 'How many data points per line should be outputted: ')
if data_points_per_line <= 0:
session.get_io().output('Your input must be greater than zero, instead got {}'.format(str(data_points_per_line)))
time.sleep(1)
session.clear()
continue
return data_points_per_line
示例3: ensure_data_not_overwritten
# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import clear [as 别名]
def ensure_data_not_overwritten(session: Session, data_lookup: Optional[Any]) -> bool:
if data_lookup is None:
return True
while True:
session.get_io().output('Data has already been loaded for this session. Do you want to replace it? (y/n): ', end='')
user_input = session.get_io().input().lower()
if user_input == 'y':
return True
elif user_input == 'n':
return False
else:
session.get_io().error('Your response must be either "y" or "n", instead got "{}"'.format(user_input))
time.sleep(1)
session.clear()
示例4: run_console
# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import clear [as 别名]
def run_console(session: Session, menu: Menu, **kwargs: Dict[str, Any]) -> None:
session.clear()
if len(menu) == 0:
session.get_io().output("No commands present in menu. Exiting...")
return
while True:
show_menu_options(session.get_io(), menu)
try:
command_lookup = retrieve_user_command_choice(session.get_io(), menu) # type: MenuCommand
handle_valid_command(command_lookup, session, kwargs)
except IllegalCommandIndexException as illegal_input_ex:
handle_illegal_command_index_exception(illegal_input_ex, session.get_io(), menu)
except MalformedInputException as malformed_input_ex:
handle_malformed_input_exception(malformed_input_ex, session.get_io())
session.clear()
示例5: handle_valid_command
# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import clear [as 别名]
def handle_valid_command(command: MenuCommand, session: Session, args: Dict[str, Any]) -> None:
session.clear()
exit_code = command.execute(session, args) # type: ExitCode
session.get_io().output('Command "{}" completed with exit code {}'.format(command.name(), exit_code.name))
time.sleep(1)