List Combinations

Reedick, Andrew jr9445 at ATT.COM
Wed Mar 12 11:38:12 EDT 2008


> -----Original Message-----
> From: python-list-bounces+jr9445=att.com at python.org [mailto:python-
> list-bounces+jr9445=att.com at python.org] On Behalf Of Shane Geiger
> Sent: Wednesday, March 12, 2008 10:33 AM
> To: Michael Wieher
> Cc: python-list at python.org
> Subject: Re: List Combinations
> 
> >
> 
> 
> def gen(lists):
>     out =  '[' + ','.join(["v%s" % i for i in range(len(lists))]) +
']'
>     comp = ''.join([ " for v%d in lists[%d]" % (i, i) for i in
> range(len(lists))])
>     return eval('[ ' + out + comp + ' ]')
> 
> a,b,c = [1,2,3],[4,5,6],[7,8,9]
> 
> print gen([a, b, c])
> 
> 
> 
> 
> 
> --
> Shane Geiger
> IT Director
> National Council on Economic Education
> sgeiger at ncee.net  |  402-438-8958  |  http://www.ncee.net
> 


It helps to quote your source...
http://www.mail-archive.com/python-list@python.org/msg178457.html


Start here
	
http://www.mail-archive.com/python-list@python.org/msg178356.html
and go through the thread.  There are several ways to solve the problem
and we evaluated the performance and 'pythonicity' of each.  




*****

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA625





More information about the Python-list mailing list