Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.alt.folklore.computer > #50138
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | ram@zedat.fu-berlin.de (Stefan Ram) |
| Newsgroups | de.alt.folklore.computer |
| Subject | Re: COMAL |
| Date | 22 May 2025 12:24:07 GMT |
| Organization | Stefan Ram |
| Lines | 56 |
| Expires | 1 Jun 2026 11:59:58 GMT |
| Message-ID | <Python-20250522132047@ram.dialup.fu-berlin.de> (permalink) |
| References | <1006u01$2vsuo$1@news1.tnib.de> <m8vvmmFnpujU5@mid.individual.net> <100en1o$3i1vf$1@news1.tnib.de> <slrn102msu9.hp9q.hjp-usenet4@trintignant.hjp.at> <1t682cb016i265761n3e8%sfroehli@Froehlich.Priv.at> <slrn102pigt.1mav1.hjp-usenet4@trintignant.hjp.at> <11t682e0e0ai7803en3e8%sfroehli@Froehlich.Priv.at> <100l59e$hbj$1@news.bawue.net> <100la2e$82ni$1@news1.tnib.de> <100lcfc$lcu$1@news.bawue.net> <100mkh3$atd7$1@news1.tnib.de> <100miku$9k5$1@news.bawue.net> <100mnod$b5b7$1@news1.tnib.de> <100mq18$guc$2@news.bawue.net> <slrn102u52n.3mllq.hjp-usenet4@trintignant.hjp.at> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | news.uni-berlin.de A+0tOct4alJiaLqr2eXn+QerETyEfRAq1xDI/RgOoTsEEm |
| Cancel-Lock | sha1:Ji0J7/96Ae/Glz/XQZx2b8veEGc= sha256:G62HONx0iIsu/Wbh6ZOuXFPYvsFc/0a50U0L/3TedYE= |
| X-Copyright | (C) Copyright 2025 Stefan Ram. All rights reserved. Distribution through any means other than regular usenet channels is forbidden. It is forbidden to publish this article in the Web, to change URIs of this article into links, and to transfer the body without this notice, but quotations of parts in other Usenet posts are allowed. |
| X-No-Archive | Yes |
| Archive | no |
| X-No-Archive-Readme | "X-No-Archive" is set, because this prevents some services to mirror the article in the web. But the article may be kept on a Usenet archive server with only NNTP access. |
| X-No-Html | yes |
| Content-Language | de-DE-1901 |
| Xref | csiph.com de.alt.folklore.computer:50138 |
Show key headers only | View raw
"Peter J. Holzer" <hjp-usenet4@hjp.at> schrieb oder zitierte:
>Aber man könnte sowas machen:
>try:
> d = re.match(...).groupdict()
> # use dictionary d here
>except AttributeError:
> # no match
Ja. Das dictionary d erlaubt recht lesbare Programmierung:
pattern = re.compile(r'''
^\(
"(?P<first>[^"]*)"\s+ # First quoted string
"(?P<second>[^"]*)"\s+ # Second quoted string
(?P<num1>\d+\S*)\s+ # First number-like field
(?P<num2>\d+\S*)\s+ # Second number-like field
(?P<num3>\d+\S*) # Third number-like field
\)\s+
(?P<tail>.*) # Remaining string
$
''', re.VERBOSE)
match = pattern.match(line)
if match:
values = match.groupdict()
. Nun kann man Ausdrücke wie "values['num1']" verwenden, welche
durch die Verwendung von Namen wie "num1" anstelle bloßer Zahlen
gut lesbar sind.
Wenn es einem nur um Kürze geht, könnte man einmalig
import re
M = re.match # abbreviation for re.match
G = lambda m: m.groups() if m else (None,) * 5 # quick group extractor
definieren und dann
m = M(r'^\("(.*?)"\s+".*?"\s+(\d.*?)\s+(\d.*?)\s+(\d.*?)\)\s+(.*?)$', line)
value1, value2, value3, value4, value5 = G(m)
schreiben. Oder ohne "G":
m = M(r'^\("(.*?)"\s+".*?"\s+(\d.*?)\s+(\d.*?)\s+(\d.*?)\)\s+(.*?)$', line)
if m:
for i, v in enumerate(m.groups(), 1): exec(f"value{i} = {repr(v)}")
. In Python werden die üblichen Mittel der Sprache (Module,
Aufrufe, r-Strings) eben konsistent auch für reguläre Ausdrücke
eingesetzt und keine Spezialsyntax. Dies bedeutet, daß Benutzer-
bibliotheken dieselben Mittel verwenden können wie die Sprache
selber (etwa um eigene, gleichberechtigte re-Bibliotheken zu
implementieren). Es ermöglicht es auch, mit den Mitteln von Python
(wie oben) Abkürzungen zu definieren, falls man Wert darauf legt.
Back to de.alt.folklore.computer | Previous | Next — Previous in thread | Next in thread | Find similar
COMAL "F. W." <me@home.invalid> - 2025-05-16 07:53 +0200
Re: COMAL Marc Haber <mh+usenetspam1118@zugschl.us> - 2025-05-16 10:45 +0200
Re: COMAL "F. W." <me@home.invalid> - 2025-05-19 07:59 +0200
Re: COMAL Marc Haber <mh+usenetspam1118@zugschl.us> - 2025-05-19 09:36 +0200
Re: COMAL "F. W." <me@home.invalid> - 2025-05-19 11:27 +0200
Re: COMAL Eric Bruecklmeier <u@5i7.de> - 2025-05-19 11:40 +0200
Re: COMAL Marc Haber <mh+usenetspam1118@zugschl.us> - 2025-05-19 14:59 +0200
Re: COMAL Eric Bruecklmeier <u@5i7.de> - 2025-05-19 15:58 +0200
Re: COMAL Marc Haber <mh+usenetspam1118@zugschl.us> - 2025-05-19 16:37 +0200
Re: COMAL Thomas Koenig <tkoenig@netcologne.de> - 2025-05-31 10:16 +0000
Re: COMAL Eric Bruecklmeier <u@5i7.de> - 2025-06-01 17:19 +0200
Re: COMAL Kay Martinen <usenet@martinen.de> - 2025-06-01 23:57 +0200
Re: COMAL Eric Bruecklmeier <u@5i7.de> - 2025-06-02 08:16 +0200
Re: COMAL "Peter J. Holzer" <hjp-usenet4@hjp.at> - 2025-06-02 12:56 +0200
Re: COMAL ram@zedat.fu-berlin.de (Stefan Ram) - 2025-06-02 11:17 +0000
Re: COMAL Eric Bruecklmeier <u@5i7.de> - 2025-06-02 17:10 +0200
Re: COMAL Kay Martinen <usenet@martinen.de> - 2025-06-04 11:54 +0200
Re: COMAL Eric Bruecklmeier <u@5i7.de> - 2025-06-04 13:16 +0200
Re: COMAL Kay Martinen <usenet@martinen.de> - 2025-06-08 22:19 +0200
Re: COMAL Eric Bruecklmeier <u@5i7.de> - 2025-06-09 09:47 +0200
Re: COMAL Kay Martinen <usenet@martinen.de> - 2025-06-09 16:38 +0200
Re: COMAL Thomas Koenig <tkoenig@netcologne.de> - 2025-06-09 12:06 +0000
Re: COMAL Eric Bruecklmeier <u@5i7.de> - 2025-06-09 14:59 +0200
Re: COMAL Thomas Koenig <tkoenig@netcologne.de> - 2025-06-09 14:02 +0000
Re: COMAL Eric Bruecklmeier <nil@nil.nil> - 2025-06-10 08:08 +0200
Re: COMAL Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2025-06-10 09:36 +0000
Re: COMAL Eric Bruecklmeier <u@5i7.de> - 2025-06-10 12:10 +0200
Re: COMAL "Peter J. Holzer" <hjp-usenet4@hjp.at> - 2025-06-10 18:41 +0200
Re: COMAL "Peter J. Holzer" <hjp-usenet4@hjp.at> - 2025-06-10 18:37 +0200
Re: COMAL Eric Bruecklmeier <u@5i7.de> - 2025-06-10 18:49 +0200
Re: COMAL "Peter J. Holzer" <hjp-usenet4@hjp.at> - 2025-06-10 20:52 +0200
Re: COMAL ram@zedat.fu-berlin.de (Stefan Ram) - 2025-06-10 19:12 +0000
Re: COMAL ram@zedat.fu-berlin.de (Stefan Ram) - 2025-06-10 17:22 +0000
Re: COMAL Eric Bruecklmeier <u@5i7.de> - 2025-06-10 19:25 +0200
Re: COMAL "Peter J. Holzer" <hjp-usenet4@hjp.at> - 2025-06-10 20:06 +0200
Re: COMAL Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2025-06-10 06:18 +0000
OOP (was: COMAL) "Peter J. Holzer" <hjp-usenet4@hjp.at> - 2025-06-10 18:57 +0200
Re: OOP ram@zedat.fu-berlin.de (Stefan Ram) - 2025-06-10 17:34 +0000
Re: OOP ram@zedat.fu-berlin.de (Stefan Ram) - 2025-06-10 17:40 +0000
Re: COMAL "Peter J. Holzer" <hjp-usenet4@hjp.at> - 2025-05-19 20:09 +0200
Re: COMAL Kay Martinen <usenet@martinen.de> - 2025-05-19 22:19 +0200
Re: COMAL "Peter J. Holzer" <hjp-usenet4@hjp.at> - 2025-05-19 23:40 +0200
Re: COMAL ram@zedat.fu-berlin.de (Stefan Ram) - 2025-05-20 08:41 +0000
Re: COMAL Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2025-05-20 16:41 +0000
Re: COMAL Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2025-05-20 16:49 +0000
Re: COMAL Kay Martinen <usenet@martinen.de> - 2025-05-20 20:33 +0200
Re: COMAL "Peter J. Holzer" <hjp-usenet4@hjp.at> - 2025-05-20 20:54 +0200
Re: COMAL Marc Haber <mh+usenetspam1118@zugschl.us> - 2025-05-20 19:44 +0200
Re: COMAL "Peter J. Holzer" <hjp-usenet4@hjp.at> - 2025-05-20 20:29 +0200
Re: COMAL ram@zedat.fu-berlin.de (Stefan Ram) - 2025-05-20 19:00 +0000
Re: COMAL ram@zedat.fu-berlin.de (Stefan Ram) - 2025-05-20 19:10 +0000
Re: COMAL Kay Martinen <usenet@martinen.de> - 2025-05-20 21:33 +0200
Re: COMAL Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2025-05-21 17:43 +0000
Re: COMAL Gerrit Heitsch <gerrit@laosinh.s.bawue.de> - 2025-05-21 20:52 +0200
Re: COMAL Marc Haber <mh+usenetspam1118@zugschl.us> - 2025-05-21 21:37 +0200
Re: COMAL Gerrit Heitsch <gerrit@laosinh.s.bawue.de> - 2025-05-21 22:55 +0200
Re: COMAL Eric Bruecklmeier <u@5i7.de> - 2025-05-22 09:17 +0200
Re: COMAL Marc Haber <mh+usenetspam1118@zugschl.us> - 2025-05-22 09:42 +0200
Re: COMAL Gerrit Heitsch <gerrit@laosinh.s.bawue.de> - 2025-05-22 09:46 +0200
Re: COMAL Marc Haber <mh+usenetspam1118@zugschl.us> - 2025-05-22 10:37 +0200
Re: COMAL Christian Corti <use@reply.to> - 2025-05-22 11:15 +0200
Re: COMAL Gerrit Heitsch <gerrit@laosinh.s.bawue.de> - 2025-05-22 11:52 +0200
Re: COMAL Marc Haber <mh+usenetspam1118@zugschl.us> - 2025-05-22 12:35 +0200
Re: COMAL Gerrit Heitsch <gerrit@laosinh.s.bawue.de> - 2025-05-22 13:08 +0200
Re: COMAL Marc Haber <mh+usenetspam1118@zugschl.us> - 2025-05-22 15:27 +0200
Re: COMAL Christian Corti <use@reply.to> - 2025-05-22 16:14 +0200
Re: COMAL "Peter J. Holzer" <hjp-usenet4@hjp.at> - 2025-05-22 14:11 +0200
Re: COMAL ram@zedat.fu-berlin.de (Stefan Ram) - 2025-05-22 12:24 +0000
Re: COMAL ram@zedat.fu-berlin.de (Stefan Ram) - 2025-05-22 15:38 +0000
Re: COMAL ram@zedat.fu-berlin.de (Stefan Ram) - 2025-05-22 15:46 +0000
Re: COMAL Kay Martinen <usenet@martinen.de> - 2025-05-31 15:38 +0200
Re: COMAL Eric Bruecklmeier <u@5i7.de> - 2025-05-22 09:44 +0200
Re: COMAL Gerrit Heitsch <gerrit@laosinh.s.bawue.de> - 2025-05-22 09:48 +0200
Re: COMAL Eric Bruecklmeier <u@5i7.de> - 2025-05-22 10:11 +0200
Re: COMAL Eric Bruecklmeier <u@5i7.de> - 2025-05-22 10:12 +0200
Re: COMAL "Peter Heitzer" <peter.heitzer@rz.uni-regensburg.de> - 2025-05-22 08:24 +0000
Re: COMAL Marc Haber <mh+usenetspam1118@zugschl.us> - 2025-05-22 10:38 +0200
Re: COMAL Stefan Reuther <stefan.news@arcor.de> - 2025-05-22 18:45 +0200
Re: COMAL Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2025-05-22 10:22 +0000
Re: COMAL Eric Bruecklmeier <u@5i7.de> - 2025-05-22 09:16 +0200
Re: COMAL "Peter J. Holzer" <hjp-usenet4@hjp.at> - 2025-05-22 08:25 +0200
Re: COMAL ram@zedat.fu-berlin.de (Stefan Ram) - 2025-05-22 09:10 +0000
Re: COMAL Dietrich Clauss <dietrich@clauss-it.com> - 2025-05-22 11:34 +0200
Re: COMAL Marc Haber <mh+usenetspam1118@zugschl.us> - 2025-05-22 12:36 +0200
Re: COMAL "Peter Heitzer" <peter.heitzer@rz.uni-regensburg.de> - 2025-05-22 12:43 +0000
Re: COMAL "Peter J. Holzer" <hjp-usenet4@hjp.at> - 2025-05-22 15:13 +0200
Re: COMAL Gerrit Heitsch <gerrit@laosinh.s.bawue.de> - 2025-05-22 16:36 +0200
Re: COMAL "Peter J. Holzer" <hjp-usenet4@hjp.at> - 2025-05-22 16:51 +0200
Re: COMAL ram@zedat.fu-berlin.de (Stefan Ram) - 2025-05-22 15:01 +0000
Re: COMAL Gerrit Heitsch <gerrit@laosinh.s.bawue.de> - 2025-05-22 17:18 +0200
Re: COMAL Dietrich Clauss <dietrich@clauss-it.com> - 2025-05-22 20:31 +0200
Re: COMAL ram@zedat.fu-berlin.de (Stefan Ram) - 2025-05-22 19:47 +0000
Re: COMAL "Peter J. Holzer" <hjp-usenet4@hjp.at> - 2025-05-23 03:54 +0200
Re: COMAL ram@zedat.fu-berlin.de (Stefan Ram) - 2025-05-23 08:43 +0000
Re: COMAL "Peter J. Holzer" <hjp-usenet4@hjp.at> - 2025-05-23 13:56 +0200
Re: COMAL Hermann Riemann <nospam.ng@hermann-riemann.de> - 2025-05-23 15:04 +0200
Re: COMAL ram@zedat.fu-berlin.de (Stefan Ram) - 2025-05-23 13:25 +0000
Re: COMAL "Peter J. Holzer" <hjp-usenet4@hjp.at> - 2025-05-23 16:23 +0200
Re: COMAL Christian Corti <use@reply.to> - 2025-05-26 11:59 +0200
Re: COMAL Hermann Riemann <nospam.ng@hermann-riemann.de> - 2025-05-23 11:29 +0200
Re: COMAL "F. W." <me@home.invalid> - 2025-05-26 09:27 +0200
Re: COMAL Stefan Reuther <stefan.news@arcor.de> - 2025-05-20 18:47 +0200
Re: COMAL Andreas Eder <a_eder_muc@web.de> - 2025-05-27 21:56 +0200
Re: COMAL Thomas Koenig <tkoenig@netcologne.de> - 2025-05-31 13:19 +0000
Re: COMAL Eric Bruecklmeier <u@5i7.de> - 2025-05-16 11:53 +0200
Re: COMAL "F. W." <me@home.invalid> - 2025-05-19 08:01 +0200
Re: COMAL Eric Bruecklmeier <u@5i7.de> - 2025-05-19 08:14 +0200
Re: COMAL "F. W." <me@home.invalid> - 2025-05-19 08:51 +0200
Re: COMAL Eric Bruecklmeier <u@5i7.de> - 2025-05-19 09:05 +0200
Re: COMAL Kay Martinen <usenet@martinen.de> - 2025-05-19 09:02 +0200
Re: COMAL "F. W." <me@home.invalid> - 2025-05-19 09:20 +0200
Re: COMAL "Peter J. Holzer" <hjp-usenet4@hjp.at> - 2025-05-19 19:59 +0200
Re: COMAL ram@zedat.fu-berlin.de (Stefan Ram) - 2025-05-19 18:16 +0000
Re: COMAL ram@zedat.fu-berlin.de (Stefan Ram) - 2025-05-19 18:36 +0000
Re: COMAL Eric Bruecklmeier <nil@nil.nil> - 2025-05-20 07:57 +0200
Re: COMAL Eric Bruecklmeier <nil@nil.nil> - 2025-05-20 07:48 +0200
csiph-web