Get terminal size in perl and python

Kalle Svensson kalle at
Thu Mar 8 20:24:36 CET 2001

Sez Egbert Bouwman:
> My perl correspondent uses:
>     use Term::ReadKey;
>     ($cols,$lines)=GetTerminalSize()
> What is the python equivalent ?

I'd use os.environ["COLUMNS"] and os.environ["LINES"], but I've no idea
about how portable they are.  Do you know how the perl function is

Anyway, if you're getting all fancy, perhaps it is better to use curses?

> If I don't come up with one, python looses ten points.

Is that so?  You can keep your filthy perl points! <0.7 wink>

Email: kalle at     | You can tune a filesystem, but you
Web: | can't tune a fish. -- man tunefs(8)
PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD
[Not signed due to braindamage.  Blame Microsoft Outlook Express.]

More information about the Python-list mailing list