Chris Jerdonek added the comment:

I don't disagree that this feature could be useful.  I'm just not sure it 
should go into a maintenance release.  It feels like an enhancement to me 
because to use this feature, the user will have to use the API in a way they 
haven't before, and we will probably have to do things like add documentation 
and examples for this new use case (e.g. explaining that users passing 
non-iterable choices will need to implement a user-friendly repr() for help to 
render nicely).

Also, it introduces new questions like: if we're going to be using repr() for 
that case, then why wouldn't we allow repr() to be used for iterable choices if 
the user would like to better control the behavior (e.g. for very long lists)?  
Why not have a unified way to deal with this situation (e.g. something like 
__argparse_repr__ with a better name, or else provide or document that certain 
formatters should be used)?  These don't seem like bug-fix questions.

> As far as I know, the reason argparse iterates is to bypass the object's 
> representation methods and produce custom, one-size-fits-all, usage and error 
> messages.

Another possibility is that it was the most helpful message for the use case 
the writers originally had in mind.  Certainly, for example, seeing the 
available choices '0, 1, 2, 3, 4' is more useful than seeing 'xrange(5)'.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16468>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to