terminal
Useful functions for terminal-based programs.
Changed in version 2.0.0: domdf_python_tools.terminal.get_terminal_size() was removed.
Use shutil.get_terminal_size() instead.
Classes:
|
Context manager for echoing variable assignments (in CPython). |
Functions:
|
Prints a blank line. |
|
Clears the display. |
Print the key combination needed to abort the script; dynamic depending on OS. |
|
|
Print |
-
class
Echo(indent=' ')[source] Bases:
objectContext manager for echoing variable assignments (in CPython).
- Parameters
indent (
str) – The indentation of the dictionary of variable assignments. Default'␣␣'.
Methods:
Called when entering the context manager.
__exit__(*args, **kwargs)Called when exiting the context manager.
-
clear()[source] Clears the display.
Works for Windows and POSIX, but does not clear the Python Interpreter or PyCharm’s Console.
-
interrupt()[source] Print the key combination needed to abort the script; dynamic depending on OS.
Useful when you have a long-running script that you might want to interrupt part way through.
Example:
>>> interrupt() (Press Ctrl-C to quit at any time)
-
overtype(*objects, sep=' ', end='', file=None, flush=False)[source] Print
*objectsto the text streamfile, starting with'\\r', separated bysepand followed byend.All non-keyword arguments are converted to strings like
strdoes and written to the stream, separated bysepand followed byend.If no objects are given,
overtype()will just write"\\r".- Parameters
*objects – A list of strings or string-like objects to write to the terminal.
sep (
str) – The separator between values. Default'␣'.end (
str) – The final value to print. Default''.file (
Optional[IO]) – An object with awrite(string)method. If not present orNone,sys.stdoutwill be used.flush (
bool) – IfTruethe stream is forcibly flushed after printing. DefaultFalse.