I can determine the width of the terminal in Python with a subprocess-handled query such as the following:
int(subprocess.Popen(['tput', 'cols'], stdout = subprocess.PIPE).communicate()[0].strip('\n'))
How could I determine the Bash user name in a similar way? So, how could I see the value of ${USER} in Python using subprocess?
subprocess? The python process itself has access to the environment.os.environfor this. e.g.print(os.environ['USER'])subprocessmethods. I am not sure how to do this. Accessing the environment variable ${USER} is a simple example.shutil.get_terminal_size()function in Python 3.3+, to get width/height of the terminal.