def getwinsize():
 if ('TIOCGWINSZ' in dir(termios)):
  TIOCGWINSZ = termios.TIOCGWINSZ
 else:
  TIOCGWINSZ = 1074295912
 s = struct.pack('HHHH', 0, 0, 0, 0)
 x = fcntl.ioctl(sys.stdout.fileno(), TIOCGWINSZ, s)
 return struct.unpack('HHHH', x)[0:2]

def getwinsize ( ) : if ( 'TIOCGWINSZ' in dir ( termios ) ) : TIOCGWINSZ = termios . TIOCGWINSZ else : TIOCGWINSZ = 1074295912 s = struct . pack ( 'HHHH' , 0 , 0 , 0 , 0 ) x = fcntl . ioctl ( sys . stdout . fileno ( ) , TIOCGWINSZ , s ) return struct . unpack ( 'HHHH' , x ) [ 0 : 2 ]
this returns the window size of the child tty .