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 larry
Recipients ezio.melotti, larry, rhettinger, serhiy.storchaka, terry.reedy, vajrasky
Date 2014-01-24.10:59:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1390561188.59.0.955200572614.issue19145@psf.upfronthosting.co.za>
In-reply-to
Content
Your patch does not address my concern.

My concern is that itertools.repeat doesn't parse its arguments like other Python functions.  It behaves differently depending on whether "times" is passed by position or by keyword.  Therefore its actual calling signature cannot be represented accurately with an inspect.Signature object.

Let me state this precisely.  Currently, inspect.signature doesn't produce a Signature object for itertools.repeat.  But let's assume for the moment that it did, and that the default value for the "times" parameter was -1.  Then, for this code:

  sig = inspect.signature(itertools.repeat)
  a = itertools.repeat('a')
  b = itertools.repeat('a', sig.parameters['times'].default)
  c = itertools.repeat('a', times=sig.parameters['times'].default)

I'd expect the a, b, and c objects to behave identically and be interchangeable.  Passing in the default value for an optional parameter should always produce the same result as not passing in a value for that parameter, and for positional-or-keyword parameters it shouldn't matter whether that's done by position or by keyword.

However, b is different from a and c: a and c yields infinitely-many 'a's, whereas b never yields anything.

I want to see a patch where, after applying the patch, a b and c would be interchangeable.  Such a patch should be *simpler* than the existing code, as it would remove all the special-case code that examines the length of the args tuple.

"Special cases aren't special enough to break the rules."  I think itertools.repeat's argument parsing should stop breaking the rules.
History
Date User Action Args
2014-01-24 10:59:48larrysetrecipients: + larry, rhettinger, terry.reedy, ezio.melotti, serhiy.storchaka, vajrasky
2014-01-24 10:59:48larrysetmessageid: <1390561188.59.0.955200572614.issue19145@psf.upfronthosting.co.za>
2014-01-24 10:59:48larrylinkissue19145 messages
2014-01-24 10:59:47larrycreate