Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <mailman.105.1717973614.2909.python-list@python.org>
Deutsch   English   Français   Italiano  
<mailman.105.1717973614.2909.python-list@python.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: MRAB <python@mrabarnett.plus.com>
Newsgroups: comp.lang.python
Subject: Re: in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3))
Date: Sun, 9 Jun 2024 23:50:26 +0100
Lines: 26
Message-ID: <mailman.105.1717973614.2909.python-list@python.org>
References: <v456ak$3pmpo$1@dont-email.me>
 <e149526e-91aa-4dfe-963e-d371ed3d280b@mrabarnett.plus.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de gm2x5jnUJzg6Ebp+JyG8BQGPk2DGxZKYhhB9RHXXNZzw==
Cancel-Lock: sha1:08boEsHkoUaCQeH37m0iTDjkLjE= sha256:9F7kPOQKy2IuhfZ90+t69B0cDoQc9E/HQIXSOHVvqFc=
Return-Path: <python@mrabarnett.plus.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=plus.com header.i=@plus.com header.b=Gxh05UE4;
 dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.005
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python?': 0.03;
 'from:addr:python': 0.09; 'received:192.168.1.64': 0.09;
 'subject:Python': 0.12; '(b)': 0.16; '(bar': 0.16;
 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16;
 'message-id:@mrabarnett.plus.com': 0.16; 'received:plus.net':
 0.16; 'wrote:': 0.16; 'to:addr:python-list': 0.20; 'skip:_ 10':
 0.22; 'header:User-Agent:1': 0.30; 'python-list': 0.32;
 'received:192.168.1': 0.32; 'header:In-Reply-To:1': 0.34; 'bar':
 0.35; 'received:192.168': 0.37; 'use': 0.39; 'received:212': 0.62;
 '==>': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019;
 t=1717973427; bh=5usnBycXd9GRnJKkyMe26zE2yS+zPW3MDvG9FWgaJzo=;
 h=Date:Subject:To:References:From:In-Reply-To;
 b=Gxh05UE4ZLYT4kb2JgCb/Kghm0ZTOO/jKGcYcX2RMiTjuggZ+TV050eV4yChxHa3f
 5LzF53tsUD21ihcTZOuHFLO3qhnJioPDsA8q8XrWviw6VHJ9Qyw5GLzn1ZvYNDjVse
 WXnDLjsIq0ien7jU3AGGentCJsRT7NzcYvzhBcSS4JVEHXDal4lyAKw9XIne2KrA9L
 xr6nvdb7C6AY9r2nQvSWXe6WPDKQfyN9XrdVHH1sTNTMdjz3593KPaBFO+wyMRvc8E
 wwM7XO5aOy3doLKSr+B2XbT0JyubnctIP196Lk2qtB2LhhLDyzKEF/Yuk06O4HGURN
 mMuLkHRMOlvZA==
X-Clacks-Overhead: "GNU Terry Pratchett"
X-CM-Score: 0.00
X-CNFS-Analysis: v=2.4 cv=NPx2+F6g c=1 sm=1 tr=0 ts=666631b3
 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17
 a=qEgh2NhK6qfR2VOi:21 a=IkcTkHD0fZMA:10 a=ctex4qzJY_x0heW7hEsA:9
 a=QEXdDO2ut3YA:10
X-AUTH: mrabarnett@:2500
User-Agent: Mozilla Thunderbird
Content-Language: en-GB
In-Reply-To: <v456ak$3pmpo$1@dont-email.me>
X-CMAE-Envelope: MS4xfAcSWBmc9UMJdNZl4kTFAH0YoT3fwYs91TPt/gqJA3fyMzeTlEaxibsyp7lTJpSZ7nADWG4xOHs2IA9TcwhvgRggTQcOk3Ab5Qur/U4Y2n6WJ5L2SCsq
 B2Tl8FFGm2bw2ME3hfDY5I+bhZDEPZ3hwufqv/Zoqpr3qJIe1tarq7Ga/JN1t4aWLNCL1Gj2m5Oc8rc8HKH+ksjhoIXGdFjXPgA=
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: <e149526e-91aa-4dfe-963e-d371ed3d280b@mrabarnett.plus.com>
X-Mailman-Original-References: <v456ak$3pmpo$1@dont-email.me>
Bytes: 4361

On 2024-06-09 22:20, HenHanna via Python-list wrote:
> 
> Chunk, ChunkC -- nice simple way(s) to write these in Python?
> 
> 
> (Chunk  '(a a   b    a a a   b b))
>       ==> ((a a) (b)  (a a a) (b b))
> 
> 
> (Chunk  '(a a a a   b   c c   a a   d   e e e e))
>       ==> ((a a a a) (b) (c c) (a a) (d) (e e e e))
> 
> 
> (Chunk  '(2 2   foo   bar bar   j j j   k   baz baz))
>       ==> ((2 2) (foo) (bar bar) (j j j) (k) (baz baz))
> 
> _________________
> 
> (ChunkC  '(a a   b b b))
>        ==> ((a 2)  (b 3))
> 
> (ChunkC  '(a a   b      a a a   b b))
>        ==> ((a 2)  (b 1)  (a 3)   (b 2))

You can make use of itertools.groupby.