Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Are you perchance running on a 64-bit machine? -- Larry Wall in <199711102149.NAA16878@wall.org>


devel / comp.lang.python / Re: All permutations from 2 lists

SubjectAuthor
o Re: All permutations from 2 listsLarry Martell

1
Re: All permutations from 2 lists

<mailman.92.1646231390.2329.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17267&group=comp.lang.python#17267

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: larry.ma...@gmail.com (Larry Martell)
Newsgroups: comp.lang.python
Subject: Re: All permutations from 2 lists
Date: Wed, 2 Mar 2022 09:29:10 -0500
Lines: 49
Message-ID: <mailman.92.1646231390.2329.python-list@python.org>
References: <CACwCsY4EQHJLr3k6G5nKdxp+Z0z_-gOLCFFtyEyDiAzym70xeA@mail.gmail.com>
<Yh64QGJVQllpgenC@scrozzle>
<CACwCsY5yWusEWf9S6N8gCZ7ZtepwR=jBsiRqo4n7zheBMNSwhw@mail.gmail.com>
<f80357f5-9216-16aa-23e5-7ea4cce53c0b@vub.be>
<CACwCsY601s2HTa-0Upkj=90p2-2fZx8H8tXReCXUKd8ucdfgwQ@mail.gmail.com>
<aaf73bb6-914b-9888-af18-d2b27e7ab431@vub.be>
<CACwCsY50h_0U5dGObUs1kyxyzMX4v24p5pF-7r2sBv3CyhvORQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de N1BFIv02or+br09PjiWuYAYkqWZWfK3zF+TJO74LCbkg==
Return-Path: <larry.martell@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=n8Ksyz4U;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.019
X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; '2022': 0.05; 'mar': 0.07;
'cc:addr:python-list': 0.09; 'skip:[ 30': 0.09; '8:37': 0.16;
'>>>>': 0.16; '>>>>>': 0.16; 'antoon': 0.16; 'cc:name:python':
0.16; 'collection.': 0.16; 'empty,': 0.16; 'itertools': 0.16;
'length.': 0.16; 'pardon': 0.16; 'query.': 0.16; 'schreef': 0.16;
'subject:lists': 0.16; 'tuples': 0.16; 'wrote:': 0.16; 'tue,':
0.19; 'cc:addr:python.org': 0.20; 'list,': 0.24; "i'd": 0.24;
'cc:2**0': 0.25; 'seems': 0.26; 'tried': 0.26; '>>>': 0.28;
'seem': 0.31; "doesn't": 0.32; 'question': 0.32; 'empty': 0.32;
'guess': 0.32; 'lists,': 0.32; 'message-id:@mail.gmail.com': 0.32;
'but': 0.32; 'there': 0.33; 'mean': 0.34; 'header:In-Reply-To:1':
0.34; 'received:google.com': 0.34; 'from:addr:gmail.com': 0.35;
'lists': 0.37; 'subject:from': 0.37; 'received:209.85': 0.37;
'could': 0.38; 'received:209': 0.39; 'two': 0.39; 'valid': 0.39;
'list': 0.39; 'received:209.85.222': 0.39; 'wed,': 0.39; 'wrote':
0.39; 'case.': 0.40; 'want': 0.40; 'should': 0.40; 'pass': 0.64;
'down': 0.64; 'your': 0.64; 'less': 0.65; 'items': 0.68; 'skip:i
40': 0.68; 'following:': 0.69; 'perfectly': 0.69; 'deal': 0.73;
'handles': 0.76; 'need.': 0.84; 'subject:All': 0.84; 'want.': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:cc; bh=Odf5aANmtwGs+/yk1uu9QyNdMfbi/xkBny3KrFuvuqA=;
b=n8Ksyz4UsbbsknarW/xuFSeCXdIbkhYHlXrYAD8ZaMquxHxBqDUY/uYKeFxWpifK6K
gRfGyJESXS1t0GA7EgRN+pXvhuE+XTmBcgg6OD/llIiX3dtgoZsvjwJPQ5DT6Vn3ka06
Ks4OLhVcReN9Ty202VGtUtBw0MFZwnYS5JDMI57bFxya15tbz8J+J8yK8g0ZmoPqyO96
S7T0OEWY5PYqwK2TNrj2/EuKXHOA/LcPo+iEsw4vVvEKu+jRqlIwovnpy2nsTMwJ5+uO
pgivEeWkXtTwo32Cg5rd7msydL50K8VaIOPO0BGG0OKvRexBLYuXWfz/1dyAoe35YWYM
dXQA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:cc;
bh=Odf5aANmtwGs+/yk1uu9QyNdMfbi/xkBny3KrFuvuqA=;
b=ZOftXwBWzss6MitMFIJNAIzdDLFRFbJy6Y0Hts902bZHhk9jEqlegBDviFRH2VszpB
xe1YRiQmmb7EEvi35x3/J1MPlCGlk9WPoU1Ce+HH6lun8Epx95Ayj9mRIldl27/jNBUR
yQJfdGPsoM4Iqct7n47X8nF3Dyn6q65ag3XRKOGjSGt4RFuSODq0Y5hi030BSN4BoPPZ
ACSOLTEj7JxdUbmsMu0f8MwR3L1OUYy86/tunn8yENS8D//mWKhQER4D16doyFL7T3kJ
dEyGlRVur42+Bp3u5Jn0Y9Zp52lGDpPtRUNeyIO1+qL/AJwPICLLhxRr1uzsKaEIFZGM
azjA==
X-Gm-Message-State: AOAM533y7nh/BRs3fYklSbn7HLiWi0biIlUHd/ITBr33qh+Mk8c9fdvD
NYtsUbTxaPdrO9DCIbH62HfAaRhwsJrx7Ozp/GikZl4=
X-Google-Smtp-Source: ABdhPJz4jGpwBV85QnKQkcNiUwaWqqvHClPuzcxUpgc2wWHni55vAAwnbyNYoe8gBIJnuZ55wGJEUvkmxydvrvTp2Ok=
X-Received: by 2002:a37:414:0:b0:508:86c3:ecd0 with SMTP id
20-20020a370414000000b0050886c3ecd0mr15893857qke.649.1646231387508; Wed, 02
Mar 2022 06:29:47 -0800 (PST)
In-Reply-To: <aaf73bb6-914b-9888-af18-d2b27e7ab431@vub.be>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CACwCsY50h_0U5dGObUs1kyxyzMX4v24p5pF-7r2sBv3CyhvORQ@mail.gmail.com>
X-Mailman-Original-References: <CACwCsY4EQHJLr3k6G5nKdxp+Z0z_-gOLCFFtyEyDiAzym70xeA@mail.gmail.com>
<Yh64QGJVQllpgenC@scrozzle>
<CACwCsY5yWusEWf9S6N8gCZ7ZtepwR=jBsiRqo4n7zheBMNSwhw@mail.gmail.com>
<f80357f5-9216-16aa-23e5-7ea4cce53c0b@vub.be>
<CACwCsY601s2HTa-0Upkj=90p2-2fZx8H8tXReCXUKd8ucdfgwQ@mail.gmail.com>
<aaf73bb6-914b-9888-af18-d2b27e7ab431@vub.be>
 by: Larry Martell - Wed, 2 Mar 2022 14:29 UTC

On Wed, Mar 2, 2022 at 9:10 AM Antoon Pardon <antoon.pardon@vub.be> wrote:
>
> Op 2/03/2022 om 14:44 schreef Larry Martell:
> > On Wed, Mar 2, 2022 at 8:37 AM Antoon Pardon<antoon.pardon@vub.be> wrote:
> >>
> >> Op 2/03/2022 om 14:27 schreef Larry Martell:
> >>> On Tue, Mar 1, 2022 at 7:21 PM<2QdxY4RzWzUUiLuE@potatochowder.com> wrote:
> >>>> On 2022-03-01 at 19:12:10 -0500,
> >>>> Larry Martell<larry.martell@gmail.com> wrote:
> >>>>
> >>>>> If I have 2 lists, e.g.:
> >>>>>
> >>>>> os = ["Linux","Windows"]
> >>>>> region = ["us-east-1", "us-east-2"]
> >>>>>
> >>>>> How can I get a list of tuples with all possible permutations?
> >>>>>
> >>>>> So for this example I'd want:
> >>>>>
> >>>>> [("Linux", "us-east-1"), ("Linux", "us-east-2"), ("Windows",
> >>>>> "us-east-1"), "Windows", "us-east-2')]
> >>>>>
> >>>>> The lists can be different lengths or can be 0 length. Tried a few
> >>>>> different things with itertools but have not got just what I need.
> >>>> [(o, r) for o in os for r in region]
> >>> This does not work if region = []. I wrote in my question that either
> >>> list could be empty.
> >> What do you mean it doesn't work? The result seems to be an empty list,
> >> which IMO is a perfectly valid result.
> >>
> >> All possible permutations over two collections where one collection is
> >> empty, should IMO give you an empty collection.
> > If one list is empty I want just the other list. What I am doing is
> > building a list to pass to a mongodb query. If region is empty then I
> > want to query for just the items in the os list. I guess I can test
> > for the lists being empty, but I'd like a solution that handles that
> > as down the road there could be more than just 2 lists.
>
> How about the following: Keep a list of your lists you want to permute over.
> Like the following:
>
> permutation_elements = [["Linux","Windows"],["us-east-1", "us-east-2"]]
>
> permutation = itertools.product(*permutation_elements)
>
> If you don't include the empty list, you will get more or less what you
> seem to want.

But I need to deal with that case.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor