Yeah, that shlex implemenattion might be used in a different situation.
I’ll recommend to use the os module, it’s quite simple to use, as an example:
os.system(“echo 1 > /proc/sys/net/ipv4/ip_forward”)
I have used this my self and works pretty well.
Hope it helps!