Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

You are only young once, but you can stay immature indefinitely.


comp / comp.lang.python / RE: A missing iterator on itertools module?

SubjectAuthor
o RE: A missing iterator on itertools module?<avi.e.gross

1
Subject: RE: A missing iterator on itertools module?
From: <avi.e.gross@gmail.com>
Newsgroups: comp.lang.python
Date: Wed, 3 Apr 2024 12:14 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: <avi.e.gross@gmail.com>
Newsgroups: comp.lang.python
Subject: RE: A missing iterator on itertools module?
Date: Wed, 3 Apr 2024 08:14:53 -0400
Lines: 52
Message-ID: <mailman.61.1712146500.3468.python-list@python.org>
References: <66059eb6$0$7522$426a34cc@news.free.fr>
<a8821ec9-2388-4c33-b743-a4ed6f550b99@vub.be>
<004501da85c0$89673b70$9c35b250$@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de fMvnBwKwVAVEohHTkWhZmQWuSd12i9/ETw4YSq5L+nTQ==
Cancel-Lock: sha1:rOOSbkE1hx/zO0CXvWFIthTACr8= sha256:Eic9uXAUMuor44fSB86JpOhJBW4Xhy13+kV/tbafjfE=
Return-Path: <avi.e.gross@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=NnP8LWeW;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.016
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'partial': 0.07;
'subject:module': 0.07; 'ast': 0.09; 'received:108': 0.09;
'url:mailman': 0.15; "'d',": 0.16; '2024': 0.16; '5:11': 0.16;
'along.': 0.16; 'antoon': 0.16; 'itertools': 0.16; 'mentions':
0.16; 'option.': 0.16; 'pardon': 0.16; 'perhaps,': 0.16; 'received
:mail-qv1-xf29.google.com': 0.16; 'schreef': 0.16; 'shorter':
0.16; 'solution:': 0.16; 'subject:missing': 0.16; 'message-
id:@gmail.com': 0.18; 'to:addr:python-list': 0.20; 'anything':
0.25; 'skip:- 10': 0.25; 'url-ip:188.166.95.178/32': 0.25; 'url-
ip:188.166.95/24': 0.25; 'url:listinfo': 0.25; 'url-
ip:188.166/16': 0.25; 'wednesday,': 0.26; 'function': 0.27;
'done': 0.28; 'url-ip:188/8': 0.31; 'python-list': 0.32; 'but':
0.32; 'there': 0.33; 'same': 0.34; "didn't": 0.34; 'header:In-
Reply-To:1': 0.34; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.35; 'change': 0.36; 'missing': 0.37;
'could': 0.38; 'still': 0.40; 'should': 0.40; 'from:': 0.62;
'to:': 0.62; 'job.': 0.62; 'skip:z 10': 0.62; 're:': 0.64; 'your':
0.64; 'came': 0.65; 'parts': 0.65; 'produce': 0.65; 'order.':
0.69; 'result,': 0.69; 'delivers': 0.76; 'sent:': 0.78; 'parts.':
0.84; 'strings': 0.84; 'stopping': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1712146498; x=1712751298; darn=python.org;
h=thread-index:content-language:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:from:to:cc:subject:date:message-id:reply-to;
bh=Y+vyzHHa+35TFsNZhV3sbm3HtBLXaa34g6Q/ZWBn4lI=;
b=NnP8LWeWm9oLNKr4r7Zn6P7iJw00HdJ38BKxD267xLIWH3PpnnYuG6JcQgI9CAam0z
M+xgvdy3EUB2Sdd+dgytau0tWP9lGNqUK/cGSe//p46aAYSdLBCpkZaMId3Y+7zzL89b
b9C1deSVk2+fXfRWCLrycCwwhT3Or4pyMr+TiYky6THxo1Y/cYQmbqZeqFLLFMAIo4ao
Dg5KadEofJCk9VHNhMYr1ZRY4W/BblcvB8ygLH98RRF4l4lsSbR6aUvdaxfg06I1WgbG
7df7aoCBQe+/goDLH+XBWc3o5o13BitGS173kB2bhzDBpWhjN6woZseIewdLrz8Gsi3Y
/0jQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1712146498; x=1712751298;
h=thread-index:content-language:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=Y+vyzHHa+35TFsNZhV3sbm3HtBLXaa34g6Q/ZWBn4lI=;
b=R4J/Z2n81lf7zh/rmn4yi0IEDv0ADN8YFQJQhhCfmlQhG2err3006lE0FpH44xwuJn
yhRI4pbB8TkOGX275KW3K6x21p9lTnvtbf9piOlwaPcwnocIQFocQSqdygMSkEPcil+F
iVAupMxeCJOxqzXx5XGXW3Q+vWvDOvOkOwwpg/Enfp6ALbdvZjTwji+poczQM0gNqlHN
TVxH1jeQZSO+Hgx5X/pCSfSVrJJFsfxw7ClEILTf307s1/LcexVS9zThbM2emYbyrOOo
8KOxwonwsLuH5q/ZPT2X/ql4eMHBNIO71QOAYp2FM0rTKKTvaV903kZ3cUdxf2CMKeU0
sokg==
X-Forwarded-Encrypted: i=1;
AJvYcCU2kGLrd1sYrwrK1dfj2mAYFDNRpIhlyA0/GkbQAAUgyC3/R+09vFP6njsomcTNhtqhF66wfk563ZwFcQE+3BAypueyr+g6
X-Gm-Message-State: AOJu0YwaQLwbA8GTn5PwVpd0+kKQ6MBntDo6Mw7ocSrroh7NPepxKtBG
MQUio3Lx3wx/y5UBtMIe5XfJdAYomRXoT2UU8c2bJTykapUX5Fqc
X-Google-Smtp-Source: AGHT+IGGOgrUE9zsZPXsXQ1RqOBuFr4vsCj5Dv0C3FRtqf/qj/+0MtnlSnqBLOVGSgRHc7zUTNlsAA==
X-Received: by 2002:a0c:ea8f:0:b0:699:28b2:2dd1 with SMTP id
d15-20020a0cea8f000000b0069928b22dd1mr1175990qvp.41.1712146498462;
Wed, 03 Apr 2024 05:14:58 -0700 (PDT)
In-Reply-To: <a8821ec9-2388-4c33-b743-a4ed6f550b99@vub.be>
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-us
Thread-Index: AQLoDA44Zb1+7rwvqQQYL1T+A6T12gKzLh1kryXNnFA=
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: <004501da85c0$89673b70$9c35b250$@gmail.com>
X-Mailman-Original-References: <66059eb6$0$7522$426a34cc@news.free.fr>
<a8821ec9-2388-4c33-b743-a4ed6f550b99@vub.be>
View all headers

Antoon,

Even if the suggested solution offers a partial result, you would need
specific requirements to determine what should be done if one or more of the
parts being cycled is shorter than the others. Stopping at that point is one
option. Another is to continue but only interleave ones still producing and
in the same order.

There is a function in itertools called zip_longest() that might be
considered as it keeps going but substitutes a customizable value for
"missing" parts. You could then, perhaps, make a change so that sentinel is
not passed along.

-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On
Behalf Of Antoon Pardon via Python-list
Sent: Wednesday, April 3, 2024 5:11 AM
To: python-list@python.org
Subject: Re: A missing iterator on itertools module?

Op 28/03/2024 om 17:45 schreef ast via Python-list:
> Hello
>
> Suppose I have these 3 strings:
>
> s1 = "AZERTY"
> s2 = "QSDFGH"
> s3 = "WXCVBN"
>
> and I need an itertor who delivers
>
> A Q W Z S C E D C ...
>
> I didn't found anything in itertools to do the job.

The documentation mentions a roundrobin recipe.
>
> So I came up with this solution:
>
>
> list(chain.from_iterable(zip("AZERTY", "QSDFGH", "WXCVBN")))
>
> ['A', 'Q', 'W', 'Z', 'S', 'X', 'E', 'D', 'C', 'R', 'F', 'V', 'T', 'G',
> 'B', 'Y', 'H', 'N']

But if your strings are not equal, this will only produce a partial result.
--
https://mail.python.org/mailman/listinfo/python-list

1

rocksolid light 0.9.8
clearnet tor