Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

In the long run, every program becomes rococco, and then rubble. -- Alan Perlis


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

SubjectAuthor
o Re: All permutations from 2 listsRob Cliffe

1
Re: All permutations from 2 lists

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: rob.cli...@btinternet.com (Rob Cliffe)
Newsgroups: comp.lang.python
Subject: Re: All permutations from 2 lists
Date: Thu, 3 Mar 2022 14:43:28 +0000
Lines: 49
Message-ID: <mailman.117.1646318616.2329.python-list@python.org>
References: <1388685953.247061.1646275320253.ref@mail.yahoo.com>
<1388685953.247061.1646275320253@mail.yahoo.com>
<CACwCsY75Y4TtcY+xySf-UBoE=Mh3XbvQ7jdBaYfbhg7o_jnyGw@mail.gmail.com>
<c2b70bce-d11a-aa1a-b8db-d5c996291800@btinternet.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de ai6/4HtOXQKZu5HrwRgIEwlkZdkNE4DXDkMvSWCapL5Q==
Return-Path: <rob.cliffe@btinternet.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=btinternet.com header.i=@btinternet.com header.b=TtVF1ezn;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.050
X-Spam-Evidence: '*H*': 0.90; '*S*': 0.00; 'def': 0.04; '2022': 0.05;
'mar': 0.07; 'cc:addr:python-list': 0.09; 'filtering': 0.09;
'originally': 0.09; 'received:192.168.1.64': 0.09; 'rejected':
0.09; 'that.': 0.15; 'avi': 0.16; 'case:': 0.16; 'database.':
0.16; 'dict': 0.16; 'gross': 0.16; 'indeed': 0.16; 'rude': 0.16;
'specify': 0.16; 'subject:lists': 0.16; 'wrote:': 0.16; 'values':
0.17; 'cc:addr:python.org': 0.20; 'issue': 0.21; 'list,': 0.24;
'anything': 0.25; 'cc:2**0': 0.25; 'interests': 0.26; 'solution.':
0.26; 'email addr:python.org&gt;': 0.28; 'header:User-Agent:1':
0.30; 'seem': 0.31; 'question': 0.32; 'answers': 0.32; 'empty':
0.32; 'guess': 0.32; 'python-list': 0.32; 'received:192.168.1':
0.32; 'but': 0.32; 'there': 0.33; 'work.': 0.34; 'header:In-Reply-
To:1': 0.34; 'trying': 0.35; 'request': 0.35; 'people': 0.36;
'those': 0.36; 'lists': 0.37; 'subject:from': 0.37; "it's": 0.37;
'hard': 0.37; 'others': 0.37; 'this.': 0.37; 'received:192.168':
0.37; 'way': 0.38; 'could': 0.38; 'means': 0.38; 'single': 0.39;
'list': 0.39; 'use': 0.39; 'wed,': 0.39; 'still': 0.40; 'explain':
0.40; 'received:213': 0.40; 'something': 0.40; 'gave': 0.61;
'skip:o 10': 0.61; 'come': 0.62; 'true': 0.63; 'pass': 0.64;
'willing': 0.64; 'clear': 0.64; 'down': 0.64; 'source.': 0.64;
'outside': 0.67; 'presenting': 0.69; 'repeatedly': 0.69; 'took':
0.69; 'product': 0.71; 'cross': 0.76; 'need.': 0.84; 'email
name:&lt;python-list': 0.84; 'field,': 0.84; 'pairs': 0.84; 'rob':
0.84; 'subject:All': 0.84; 'waited': 0.84; 'skip:q 20': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=btinternet.com;
s=btmx201904; t=1646318609;
bh=lDHlYmqpxwGU1LpgQELujjNBXHDe9X80bLc5Lh0EgvY=;
h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To;
b=TtVF1eznX8HCR8lsQgnIiXbok/H5DhVI2HWMbt87ok8X8cfI/0R0zMaABmReiey6VCFTQUBm/5IV3n91WO+0HNuU6+0KB1YyhrgJ7fy9SJx3rmYROMIwCFyC3n0iPPUflNZPQRXVO1+rmCcSYi+0xv7l+zrky96HjB9nAbL017oM4qpf/vHBEdK5L10SDCYwmSuvFYQv7uhqbiL5nF4o4FAOu505JvHklaWRQHvUVjP3jSodkQrmzpDvdRB98PFYaSRR7ObHSKtn0Y3K5EKuPN8B2hWxoVmR4TtM5sQqh+Ip/hxlkrirb0oC44ny2KI/EJHJj6n3jXVp3MxtvLRUsw==
Authentication-Results: btinternet.com;
auth=pass (PLAIN) smtp.auth=rob.cliffe@btinternet.com;
bimi=skipped
X-SNCR-Rigid: 613943C617E79606
X-Originating-IP: [86.173.124.29]
X-OWM-Source-IP: 86.173.124.29 (GB)
X-OWM-Env-Sender: rob.cliffe@btinternet.com
X-VadeSecure-score: verdict=clean score=0/300, class=clean
X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgedvvddruddtiedgieeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuueftkffvkffujffvgffngfevqffopdfqfgfvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpegtkfffgggfuffvfhfhjgesrgdtreertdefjeenucfhrhhomheptfhosgcuvehlihhffhgvuceorhhosgdrtghlihhffhgvsegsthhinhhtvghrnhgvthdrtghomheqnecuggftrfgrthhtvghrnhepudetgfeuudevveellefhhfeguefhfeevudduhfdvffehveehhfevvdejieejtedtnecukfhppeekiedrudejfedruddvgedrvdelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehhvghloheplgduledvrdduieekrddurdeigegnpdhinhgvthepkeeirddujeefrdduvdegrddvledpmhgrihhlfhhrohhmpehrohgsrdgtlhhifhhfvgessghtihhnthgvrhhnvghtrdgtohhmpdhnsggprhgtphhtthhopedvpdhrtghpthhtoheplhgrrhhrhidrmhgrrhhtvghllhesghhmrghilhdrtghomhdprhgtphhtthhopehphihthhhonhdqlhhishhtsehphihthhhonhdrohhrgh
X-RazorGate-Vade-Verdict: clean 0
X-RazorGate-Vade-Classification: clean
X-SNCR-hdrdom: btinternet.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Content-Language: en-GB
In-Reply-To: <CACwCsY75Y4TtcY+xySf-UBoE=Mh3XbvQ7jdBaYfbhg7o_jnyGw@mail.gmail.com>
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
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: <c2b70bce-d11a-aa1a-b8db-d5c996291800@btinternet.com>
X-Mailman-Original-References: <1388685953.247061.1646275320253.ref@mail.yahoo.com>
<1388685953.247061.1646275320253@mail.yahoo.com>
<CACwCsY75Y4TtcY+xySf-UBoE=Mh3XbvQ7jdBaYfbhg7o_jnyGw@mail.gmail.com>
 by: Rob Cliffe - Thu, 3 Mar 2022 14:43 UTC

On 03/03/2022 14:07, Larry Martell wrote:
> On Wed, Mar 2, 2022 at 9:42 PM Avi Gross via Python-list
> <python-list@python.org> wrote:
>> Larry,
>>
>> i waited patiently to see what others will write and perhaps see if you explain better what you need. You seem to gleefully swat down anything offered. So I am not tempted to engage.
> But then you gave in to the temptation.
>
>> And it is hard to guess as it is not clear what you will do with this.
> In the interests of presenting a minimal example I clearly
> oversimplified. This is my use case: I get a dict from an outside
> source. The dict contains key/value pairs that I need to use to query
> a mongodb database. When the values in the dict are all scalar I can
> pass the dict directly into the query, e.g.:
> self._db_conn[collection_name].find(query). But if any of the values
> are lists that does not work. I need to query with something like the
> cross product of all the lists. It's not a true product since if a
> list is empty it means no filtering on that field, not no filtering on
> all the fields. Originally I did not know I could generate a single
> query that did that. So I was trying to come up with a way to generate
> a list of all the permutations and was going to issue a query for each
> individually. Clearly that would become very inefficient if the lists
> were long or there were a lot of lists. I then found that I could
> specify a list with the "$in" clause, hence my solution.
>
>> def query_lfixer(query):
>> for k, v in query.items():
>> if type(v)==list:
>> query[k] = {"$in": v}
>> return query
>>
>> self._db_conn[collection_name].find(query_lfixer(query))
>>
>>
>> So why did so many of us bother?
> Indeed - so why did you bother?
You started with a request for help that did not say what you actually
wanted.
When people took the time and trouble to give you answers to the
question **as posed**, you repeatedly rejected them while still being
unclear about what you actually wanted.
Now you seem to be being rude to Avi.
There are plenty of people willing to help on this list, and plenty of
goodwill to those that need help - but goodwill can be used up if it is
abused.
Respectfully,
Rob Cliffe

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor