How to easily display multiple columns in the console with curses?
<p>I would like to print data in the console in multiple columns with curses. What is an easy approach to do so?</p>

<p>Currently, my application prints information like this:</p>

<pre><code>import curses
(...)
# create default screen
std_scr = curses.initscr()
(...)
# example
for line in lines:
    std_scr.addstr(line + "\n")
std_scr.refresh()
</code></pre>

<p>This results in the following output</p>

<pre><code>line 1
line 2
...
line n
</code></pre>

<p>However, what I would like to have, is something like this:</p>

<pre><code>columns = 3
for line in lines:
   # easy way to separate columns
</code></pre>

<p>Which should result in:</p>

<pre><code>line 1         | line 11          | line 21
line 2         | line 12          | line 22
...            | ...              | ...
line 10        | line 20          | line 30
</code></pre>

<p>What is an easy way to achieve this? Should I simply use an iterator to iterate in a order like <code>line 1</code>, <code>line 11</code>, <code>line 21</code>, <code>line 2</code>, <code>line 12</code>, <code>line 22</code>, <code>line 3</code>, and so forth, while using <code>line.ljust(30, " ")</code> to get the whitespaces?</p>

<p>Or should I create multiple screens in curses?</p>

<p>Do other, even simpler solutions exist?</p>

<p>I'm pretty new to curses, thus any general advice + example would be great.</p>