: Re:
>> Creating unique combinations from lists
>>
>> Yick...a nice demo of the power of eval, but definitely filed under the
>> "Hack" heading
>
> You hurt my feeling. *sniffle* Given how late python
> compiles/evaluates code blocks, I'm thinking that ev
> -Original Message-
> From: Tim Chase [mailto:[EMAIL PROTECTED]
> Sent: Thursday, January 17, 2008 10:30 AM
> To: Reedick, Andrew
> Cc: breal; python-list@python.org; [EMAIL PROTECTED]
> Subject: Re: Creating unique combinations from lists
>
> Yick...a nice demo o
>> You can use a recursive generator:
>>
>>def iterall(*iterables):
>> if iterables:
>>for head in iterables[0]:
>> for remainder in iterall(*iterables[1:]):
>>yield [head] + remainder
>> else:
>>yield []
>>
>>for thing in iterall(
>>['
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:python-
> [EMAIL PROTECTED] On Behalf Of Tim Chase
> Sent: Wednesday, January 16, 2008 3:40 PM
> To: breal
> Cc: python-list@python.org
> Subject: Re: Creating unique combinations from lists
>
> You ca
> The main emphasis was to show that there was a pattern unfolding that
> should have been translated into more pythonic code than just
> hard-coding nested loops.
Practicality beats purity. That you would solve a more general problem
in a more general way doesn't mean that you shouldn't solve the
>> for a in range(5):
> ...
>>for z in range(5):
>
> means the inner loop runs 5**26 times so perhaps it's not only
> unpythonic but also uncomputable...
only if you're impatient ;)
yes, it was a contrived pessimal example. It could be range(2)
to generate boolean
>
> for a in range(5):
...
>for z in range(5):
means the inner loop runs 5**26 times so perhaps it's not only
unpythonic but also uncomputable...
--
http://mail.python.org/mailman/listinfo/python-list
>> I could do nested for ... in loops, but was looking for a Pythonic way
>> to do this. Ideas?
>
> What makes you think nested loops aren't Pythonic?
On their own, nested loops aren't a bad thing. I suspect they
become un-Pythonic when they make code look ugly and show a
broken model of the
On Wed, 16 Jan 2008 11:15:16 -0800, breal wrote:
> I could do nested for ... in loops, but was looking for a Pythonic way
> to do this. Ideas?
What makes you think nested loops aren't Pythonic?
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
On Jan 16, 11:15 am, breal <[EMAIL PROTECTED]> wrote:
> I have three lists... for instance
>
> a = ['big', 'small', 'medium'];
> b = ['old', 'new'];
> c = ['blue', 'green'];
>
> I want to take those and end up with all of the combinations they
> create like the following lists
> ['big', 'old', 'blu
> a = ['big', 'small', 'medium'];
> b = ['old', 'new'];
> c = ['blue', 'green'];
>
> I want to take those and end up with all of the combinations they
> create like the following lists
> ['big', 'old', 'blue']
> ['small', 'old', 'blue']
> ['medium', 'old', 'blue']
> ['big', 'old', 'green']
> ['sma
> I could do nested for ... in loops, but was looking for a Pythonic way
> to do this. Ideas?
I find nested for loops very Pythonic. Explicit is better than implicit,
and simple is better than complex.
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list
On Jan 16, 11:33 am, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote:
> > -Original Message-
> > From: [EMAIL PROTECTED] [mailto:python-
> > [EMAIL PROTECTED] On Behalf Of breal
> > Sent: Wednesday, January 16, 2008 2:15 PM
> > To: [EMAIL PROTEC
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:python-
> [EMAIL PROTECTED] On Behalf Of breal
> Sent: Wednesday, January 16, 2008 2:15 PM
> To: python-list@python.org
> Subject: Creating unique combinations from lists
>
> I have three lists... for
I have three lists... for instance
a = ['big', 'small', 'medium'];
b = ['old', 'new'];
c = ['blue', 'green'];
I want to take those and end up with all of the combinations they
create like the following lists
['big', 'old', 'blue']
['small', 'old', 'blue']
['medium', 'old', 'blue']
['big', 'old',
15 matches
Mail list logo