def getheightwidth(self):
try:<EOL><INDENT>return int(os.environ["<STR_LIT>"]), int(os.environ["<STR_LIT>"])<EOL><DEDENT>except KeyError:<EOL><INDENT>height, width = struct.unpack(<EOL>"<STR_LIT>", ioctl(<NUM_LIT:0>, termios.TIOCGWINSZ ,"<STR_LIT>"*<NUM_LIT:8>))[<NUM_LIT:0>:<NUM_LIT:2>]<EOL>if not height:<EOL><INDENT>return <NUM_LIT>, <NUM_LIT><EOL><DEDENT>return height, width<EOL><DEDENT>
getwidth() -> (int, int)

        Return the height and width of the console in characters
        https://groups.google.com/forum/#!msg/comp.lang.python/CpUszNNXUQM/QADpl11Z-nAJ