This recipe is Python implementation of few lines of C-code that get useful information about current working console on Windows. It may be useful for console application to proper formatting output. Recipe need ctypes package to be installed.
This is the second version of recipe. When use handle of stdout for determining size of console and connect output of program via pipe to another program (e.g. pager 'more') then you get default 80x25 size. In case of using handle of stderr for this purpose then pipe don't destroy actual size.
Python, 20 lines
Open new console window (on Windows 2K/XP press Start -> Run -> type 'cmd' and hit Enter). Change your current directory to one that contain this script. Resize console window with mouse and run this code. It will print actual console size as: columns rows.