Terry J. Reedy <tjre...@udel.edu> added the comment:

A relatively simple change would be to allow the first iterable to be 
'infinite', when repeat==1, by not calling tuple() on it. The reason for 
turning the iterables into concrete sequences is because they might not be 
reiterable. (cycle() does the same for the same reason.) But since the first 
iterable is only iterated once, this does not apply to it.

    if repeat == 1:
        pools = [args[0:1]].extend(tuple(pool) for pool in args[1:])
    else:
        pools = [tuple(pool) for pool in args] * repeat

The counter argument to this or any generalized proposal is that one can expand 
the product() into enough loops to avoid infinite (or very large) args. For 
example, the following produces '1AA', '1AB', ..., '1EE', '2AA', ... 
indefinitely.

naa=(''.join((str(n),)+s) for n in itertools.count(1)
     for s in itertools.product(string.ascii_uppercase[0:5], repeat=2))

RAYMOND: Do you think the doc should specify that each iterable must be finite, 
and that explicit loops are the alternative if not?

----------

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

Reply via email to