This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients Juraj.Variny, bethard, chris.jerdonek, docs@python, ezio.melotti, r.david.murray, terry.reedy
Date 2012-11-14.19:38:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1352921887.44.0.27554750719.issue16418@psf.upfronthosting.co.za>
In-reply-to
Content
I agree that my extreme, strawman-ish, proposal, was, well, too extreme. Here is a more realistic proposal similar to David's.

if isinstance(choices, range) and len(choices) > 50:
  choice_txt = range_rep(choices)  # details to be determined
try:
  choice_txt = <iterated version of choices as now>
except TypeError:  # because choices not iterable
  choice_txt = repr(choices)  # can be anything for custom class

Then display help or error message.

If someone passes a non-(x)range iterable with 1000s of choices, I am willing to say they deserve what they asked for, once that the docs make clearer that such collections will be displayed in full. Any iterable container too large to display in full can be wrapped as a non-iterable container. ('Container' means that 'in' works.)

class NonIterableContainer:
  def __init__(self, container, description):
    self.container = container
    self.description = description
  def __repr__(self):
    return self.description
  def __contains__(self, item):
    return item in self.container

The description could point one to a file or doc that has an explicit list.

If such a listing enumerates the items, the program arg could instead be an int in the appropriate range. Then the program would look up the actual arg. Ranges *are* special because items from any finite enumerated collection can be replaced, for input, by the corresponding int in the enumerated range. They are therefore worth special attention in help and error displays.
History
Date User Action Args
2012-11-14 19:38:07terry.reedysetrecipients: + terry.reedy, bethard, ezio.melotti, r.david.murray, chris.jerdonek, docs@python, Juraj.Variny
2012-11-14 19:38:07terry.reedysetmessageid: <1352921887.44.0.27554750719.issue16418@psf.upfronthosting.co.za>
2012-11-14 19:38:07terry.reedylinkissue16418 messages
2012-11-14 19:38:06terry.reedycreate