Chris Jerdonek added the comment:

For the record, choices types implementing only __contains__ never worked in 
any cases.  (I should have said ArgumentParser.add_argument() raises a 
ValueError in the above.)

So I wonder if we should classify this as an enhancement and simply document 
the restriction in maintenance releases to iterable types.  Clearly the module 
was written under the assumption (in multiple places) that choices are iterable.

Also, if we do change this, perhaps we should fall back to displaying the 
metavar in help messages when naming the container rather than using repr().  A 
message like the following, for example, wouldn't be very helpful or look very 

   invalid choice: 0 (choose from <__main__.Container object at 0x10555efb0>)

I think we should avoid letting Python creep into help and usage text.

nosy: +r.david.murray

Python tracker <>
Python-bugs-list mailing list

Reply via email to