On 03/10/2010 02:20 PM, Giovanni Marco Dall'Olio wrote:
> - itertools.product dovrebbe darti il prodotto cartesiano, ma mi
> sembra che non vi sia almeno in python2.5, e per il momento non te lo
> posso provare (sono su una vecchia ubuntu).
>
Lo uso tranquillamente sulla 2.5, sono poche righe:
> # itertools.product from python 2.6
> def product(*args, **kwds):
> pools = map(tuple, args) * kwds.get('repeat', 1)
> if pools:
> result = [[]]
> for pool in pools:
> result = [x+[y] for x in result for y in pool]
> for prod in result:
> yield tuple(prod)
--
This e-mail (and any attachment(s)) is strictly confidential and for use only
by intended recipient(s). Any use, distribution, reproduction or disclosure by
any other person is strictly prohibited. The content of this e-mail does not
constitute a commitment by the Company except where provided for in a written
agreement between this e-mail addressee and the Company. If you are not an
intended recipient(s), please notify the sender promptly and destroy this
message and its attachments without reading or saving it in any manner. Any non
authorized use of the content of this message constitutes a violation of the
obligation to abstain from learning of the correspondence among other subjects,
except for more serious offence, and exposes the person responsible to the
relevant consequences.
_______________________________________________
Python mailing list
[email protected]
http://lists.python.it/mailman/listinfo/python