1: cls()
cls(). or ansi.cls(). or any way to intuitively clear the screen.
a lot of projects need frequent clearing of the terminal.
and most of them can't use TUI libraries because they need full terminal control
programmers often have to do
os.system('cls' if os.name == 'nt' else 'clear')
i propose:
cls()
or:
ansi.cls()
2: try w/ implicit except
this sounds stupid, i know.
say i wanna simply catch an error, and immediately ignore it.
currently in python you have to do
try:
riskything()
except ValueError:
pass
or you have to do
try:
riskything()
except:
pass
i propose the following is implemented
try ValueError:
riskything()
or
try:
riskything()
so programmers have an easier time catching errors and doing nothing with them
3: color()
sometimes, you want to change your terminal color.
it happens a lot in TUI projects
and god help you if you want hexcodes.
you're gonna have to write a massive function with an inline ansi mess.
so, programmers usually need any obvious way.
i propose instead of doing
import sys
def color(hexcode: str):
hexc = hexcode.strip().lstrip('#')
if len(hexc) != 6 or not all(c in "0123456789abcdefABCDEF" for c in clean_hex):
raise ValueError(f"bad hex color code: \"{hexcode}\"")
r = int(hexc[0:2], 16)
g = int(hexc[2:4], 16)
b = int(hexc[4:6], 16)
sys.stdout.write(f"\033[38;2;{r};{g};{b}m")
sys.stdout.flush()
we simply do
color(0x00ff00)
one thing: i think my suggestions need heavy consideration and not an early cutoff
and another thing: no dogma because programming topics need arguments to be defensible engineering claims that you can defend and i can argue out