Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Keep the number of passes in a compiler to a minimum. -- D. Gries


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.87.1646228719.2329.python-list@python.org>

  copy mid

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

  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 08:44:41 -0500
Lines: 37
Message-ID: <mailman.87.1646228719.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>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de +z03yHert1AuIESFUXETZgf0Xy3ht6AT+cbl/rxRKldA==
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=lAgfrrjT;
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; '8:37': 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; "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;
'received:209.85.208': 0.39; 'valid': 0.39; 'list': 0.39; 'wed,':
0.39; 'wrote': 0.39; 'want': 0.40; 'should': 0.40; 'pass': 0.64;
'down': 0.64; 'items': 0.68; 'perfectly': 0.69; 'handles': 0.76;
'need.': 0.84; 'received:209.85.208.177': 0.84; 'received:mail-
lj1-f177.google.com': 0.84; 'subject:All': 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=/zJFjEJ+1XpazkazSXu+fNfQ9aKFrTFOwdBwDNwP1fU=;
b=lAgfrrjT8EvMlkE+/Ajkiu9r1Qo35AX9q6oD+P2+VMxGGo6kgrjD76CPSpm7Olo8Kv
UhQxkthlNnoulnTtpx/Ofk9VZlgF+52k2SaP4TqJxXULkWQOb1CaKfwT55VpRZeGtMQr
l8HFmC/9z3CsKVFSRGLGhdz4/co1idYJOVVcJt4SUAbIzbCjPwV5ibjBYP7OpoFh6Opf
YmltC8IxmD4J2HU1kM85IVXfW0vaDdbz8L8XrX46+UmdXbmqFCxGgRcIj4ksN7ideMS6
rZFJsxwqwiBC1DJ0Po+bESsVvKShI+5JO5+tJFCqR/1lKpwrf58WWIDDOtOTzl5h16oR
ppUA==
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=/zJFjEJ+1XpazkazSXu+fNfQ9aKFrTFOwdBwDNwP1fU=;
b=JzMZb1CF51fKxLD7I5rgFxfizQJlrsuHMrIkjEaAkEEPwiP4N7FBPM//9KLpYLd+Tt
DJncj/YuCXsQDJURtqoW9cO1CHd/H6OwXCCTTBBkBrDCT+2xgrNppsqxvbkGADpiabGi
QzzxmE9ircd/FWnNpWm4qJb8WGwiRgRx3MmElyEleIJhdomqfDIkb1KXKesJlL76oSFF
yguf6kmhoHfrWwDyijLcvtBYvswQVyYX6ZDKaHjMyxX8KqSU+XOhPIWA9bplYlhkJxub
JRAZwGJ6tCphUBqS12jPb1LFkI7qVyObq9858mVW4fs42h2UvP9i3w78agZDZIjquAJW
gRyQ==
X-Gm-Message-State: AOAM531emgmtetbH5+wz/cSn5g/uQN1oAsnvGXHrqn+7ZCzROWQwzA2A
yeZDWc3OkJ+qUwRUoLK3ozOuAVAXDU6Ni7EiM5zpa1E=
X-Google-Smtp-Source: ABdhPJxc26IHUCX34c8kpuc4FJEcCljEo+lQydgnLXinL7a5ZsGSqovgy5vthxe8hfsAbAwb52hG/H77QqTXTOAhrkQ=
X-Received: by 2002:a2e:b0f1:0:b0:239:2415:67a7 with SMTP id
h17-20020a2eb0f1000000b00239241567a7mr19813189ljl.256.1646228717930; Wed, 02
Mar 2022 05:45:17 -0800 (PST)
In-Reply-To: <f80357f5-9216-16aa-23e5-7ea4cce53c0b@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: <CACwCsY601s2HTa-0Upkj=90p2-2fZx8H8tXReCXUKd8ucdfgwQ@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>
 by: Larry Martell - Wed, 2 Mar 2022 13:44 UTC

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.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor