Larry Hastings added the comment:

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.

----------

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

Reply via email to