Q: How to get Ubuntu Terminal's window handles using Python? For running few tests on two different serial ports i.e. ttyS0 and ttyS1, I need to work on two different terminal windows or tabs, as the commands I have to run should type simultaneously through Python script. 
My prior experience was automating some tasks on Windows OS and with the help of win32gui library for Python it was easy to get window handles.I took help from here for this HWND of each window in Python
But, I couldn't find any library that can help me around here in Ubuntu.

A: This gives you the name of the current tty in Python:
import os,sys

os.ttyname(sys.stdout.fileno())

If you need it in the Unix terminal then a simple tty is your friend. Then you can do e.g. echo hello > /dev/pts/# to write to your neighboring tab or window.
