Chris Jerdonek added the comment:

> The code could simply use the str or repr of the choice object

It seems to me that this would result in less user-friendly behavior in many 
cases.  It would also require the end-user to understand Python (e.g. xrange 
and dictionaries), which I don't think should be necessary for the user of a 
command-line script.

For example, in Python 2.7 the containers xrange(5, 10), xrange(2, 10, 2), and 
{1: "foo", 2: "bar"} currently yield the following user-friendly messages for 
choice 0:

invalid choice: 0 (choose from 5, 6, 7, 8, 9)
invalid choice: 0 (choose from 2, 4, 6, 8)
invalid choice: 0 (choose from 1, 2)

With the proposed change, these messages would be as follows, which seem 
unnecessarily obfuscated:

invalid choice: 0 (choose from xrange(5, 10))
invalid choice: 0 (choose from xrange(2, 10, 2))
invalid choice: 0 (choose from {1: 'foo', 2: 'bar'})

Thus, I think the proposal above would be a regression if applied.  I think any 
changes to maintenance releases should preserve the current user-friendly 
messages (when those messages are user-friendly, e.g. when the containers are 


Python tracker <>
Python-bugs-list mailing list

Reply via email to