Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm writing a terminal program and need to get the size of the TTY I'm using. The Internet seems to suggest this can be done with curses, but I can't seem to find out how in python. I'm trying to avoid using the ROWS and COLUMNS environment variables if possible :)

share|improve this question

Apparently, the getmaxyx() method is what you need. It returns a (height, width) tuple.

Python reference

Some tutorial

share|improve this answer
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – coversnail May 8 '12 at 8:07
Would expect to find this on SO, but nontheless, perfect answer, thanks! Signed up just to +1 this. :) – ArtOfWarfare Feb 9 '15 at 20:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.