(default=80)
return width or default
Returns console width
Returns console width
Returns console width
def getConsoleWidth(default=80):
    """
    Returns console width
    """

    width = None

    if os.getenv("COLUMNS", "").isdigit():
        width = int(os.getenv("COLUMNS"))
    else:
        try:
            try:
                FNULL = open(os.devnull, 'w')
            except IOError:
                FNULL = None
            process = execute("stty size", shell=True, stdout=PIPE, stderr=FNULL or PIPE)
            stdout, _ = process.communicate()
            items = stdout.split()

            if len(items) == 2 and items[1].isdigit():
                width = int(items[1])
        except (OSError, MemoryError):
            pass

    if width is None:
        try:
            import curses

            stdscr = curses.initscr()
            _, width = stdscr.getmaxyx()
            curses.endwin()
        except:
            pass

    return width or default
def getConsoleWidth ( default = 80 ) : width = None if os . getenv ( "COLUMNS" , "" ) . isdigit ( ) : width = int ( os . getenv ( "COLUMNS" ) ) else : try : try : FNULL = open ( os . devnull , 'w' ) except IOError : FNULL = None process = execute ( "stty size" , shell = True , stdout = PIPE , stderr = FNULL or PIPE ) stdout , _ = process . communicate ( ) items = stdout . split ( ) if len ( items ) == 2 and items [ 1 ] . isdigit ( ) : width = int ( items [ 1 ] ) except ( OSError , MemoryError ) : pass if width is None : try : import curses stdscr = curses . initscr ( ) _ , width = stdscr . getmaxyx ( ) curses . endwin ( ) except : pass return width or default