All permutations from 2 lists

gene heskett gheskett at shentel.net
Wed Mar 2 21:00:48 EST 2022


On Wednesday, 2 March 2022 17:46:49 EST Larry Martell wrote:
> On Wed, Mar 2, 2022 at 5:31 PM Joel Goldstick 
<joel.goldstick at gmail.com> wrote:
> > On Wed, Mar 2, 2022 at 5:07 PM Larry Martell 
<larry.martell at gmail.com> wrote:
> > > On Wed, Mar 2, 2022 at 5:00 PM Cameron Simpson <cs at cskk.id.au> 
wrote:
> > > > On 02Mar2022 08:29, Larry Martell <larry.martell at gmail.com> 
wrote:
> > > > >On Tue, Mar 1, 2022 at 7:32 PM Rob Cliffe 
<rob.cliffe at btinternet.com> wrote:
> > > > >> I think itertools.product is what you need.
> > > > >> Example program:
> > > > >> 
> > > > >> import itertools
> > > > >> opsys = ["Linux","Windows"]
> > > > >> region = ["us-east-1", "us-east-2"]
> > > > >> print(list(itertools.product(opsys, region)))
> > > > >
> > > > >This does not work if region = []. I wrote in question that
> > > > >either
> > > > >list could be empty.
> > > > 
> > > > What do you want to get if a list is empty? You haven't said. My
> > > > personal expectation would be an empty result.
> > > > 
> > > > Alternatively, if you expect an empty list to imply some single
> > > > default> > > 
> > > > the the experession:
> > > >     the_list or (the_default,)
> > > > 
> > > > might be of use.
> > > 
> > > I've solved the issue.
> > > --
> > > https://mail.python.org/mailman/listinfo/python-list
> > 
> > Would you be so kind as to show the results of your solution?
> 
> I posted it at 10:49am Eastern time.

You may want to repost it Larry, at 9pm eastern it has not arrived here.

Cheers, Gene Heskett.
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.
 - Louis D. Brandeis
Genes Web page <http://geneslinuxbox.net:6309/gene>





More information about the Python-list mailing list