How to pass a variable to the dialog's choices propery?
<p>I would like to have a list of connected users, have chosen dialog tui for this.
This is my first little python (3.5) script.</p>

<pre><code>import sys
import psutil
import locale
import dialog
import pprint

locale.setlocale(locale.LC_ALL, '')
d = dialog.Dialog(dialog="dialog")
choices = []
i = 0;
users = psutil.users()
for user in users:
        item = ('{0}.'.format(i), user.name)
        choices.append(item)
        i += 1
choices.append(('X', "Exit"))
#pprint.pprint(choices)
#OUTPUT: [('0.', 'root'), ('1.', 'root'), ('X', 'Exit')]
#code, tag = d.menu("List", choices)
code, tag = d.menu("List", choices=[('0.', 'root'), ('1.', 'root'), ('X', 'Exit')])
</code></pre>

<p>My question is, why is that dialog works with the choices defined inline but can
not when I just give the already defined list that is identical to the list provided in the inline definition.</p>

<pre><code>child_output.strip()))
dialog.DialogError: dialog-like terminated due to an error: the dialog-like program exited with status 3 (which was passed to it as the DIALOG_ERROR environment variable). Sometimes, the reason is simply that dialog was given a height or width parameter that is too big for the terminal in use. Its output, with leading and trailing whitespace stripped, was:

Error: Expected at least 6 tokens for --menu, have 4.
</code></pre>