How to get terminal width?

Radovan Garabik garabik at
Fri May 5 16:46:26 EDT 2000

Doug Stanfield <DOUGS at> wrote:
 : Assuming you're on a *nix platform, there is an environmental variable,
 : COLUMNS, that should be accessible.  If you use curses there is a

atlas13:pts/7:~% echo $COLUMNS
atlas13:pts/7:~% python
Python 1.5.2 (#0, Mar 12 2000, 22:39:11)  [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import os
>>> os.environ['COLUMNS']
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python1.5/", line 14, in __getitem__
    def __getitem__(self, key): return[key]

what's up?

| Radovan Garabik |
| __..--^^^--..__    garabik @     |
Antivirus alert: file .signature infected by signature virus.
Hi! I'm a signature virus! Copy me into your signature file to help me spread!

More information about the Python-list mailing list