Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

It's computer hardware, of course it's worth having <g> -- Espy on #Debian


devel / comp.lang.python / Re: on str.format and f-strings

SubjectAuthor
* on str.format and f-stringsMeredith Montgomery
+* Re: on str.format and f-stringsStefan Ram
|`* Re: on str.format and f-stringsMeredith Montgomery
| `* Re: on str.format and f-stringsJulio Di Egidio
|  `* Re: on str.format and f-stringsMeredith Montgomery
|   `* Re: on str.format and f-stringsJulio Di Egidio
|    `- Re: on str.format and f-stringsMeredith Montgomery
`* Re: on str.format and f-stringsChris Angelico
 +- Re: on str.format and f-stringsMeredith Montgomery
 `- Re: on str.format and f-stringsJulio Di Egidio

1
on str.format and f-strings

<868rmxljw2.fsf@levado.to>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!wV23SPyuRKrhUqTV5ggwqQ.user.46.165.242.91.POSTED!not-for-mail
From: mmontgom...@levado.to (Meredith Montgomery)
Newsgroups: comp.lang.python
Subject: on str.format and f-strings
Date: Mon, 05 Sep 2022 16:07:57 -0300
Organization: Aioe.org NNTP Server
Message-ID: <868rmxljw2.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="13858"; posting-host="wV23SPyuRKrhUqTV5ggwqQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
Cancel-Lock: sha1:oMVJJXNWECwv7k2jtKlKnNyEV30=
X-Notice: Filtered by postfilter v. 0.9.2
 by: Meredith Montgomery - Mon, 5 Sep 2022 19:07 UTC

It seems to me that str.format is not completely made obsolete by the
f-strings that appeared in Python 3.6. But I'm not thinking that this
was the objective of the introduction of f-strings: the PEP at

https://peps.python.org/pep-0498/#id11

says so explicitly. My question is whether f-strings can do the
following nice thing with dictionaries that str.format can do:

--8<---------------cut here---------------start------------->8---
def f():
d = { "name": "Meredith", "email": "mmontgomery@levado.to" }
return "The name is {name} and the email is {email}".format(**d)
--8<---------------cut here---------------end--------------->8---

Is there a way to do this with f-strings?

Re: on str.format and f-strings

<eval-20220905203236@ram.dialup.fu-berlin.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: on str.format and f-strings
Date: 5 Sep 2022 19:33:31 GMT
Organization: Stefan Ram
Lines: 20
Expires: 1 Sep 2023 11:59:58 GMT
Message-ID: <eval-20220905203236@ram.dialup.fu-berlin.de>
References: <868rmxljw2.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de 0X6VMc/pMFpvlOO0sKHacgd3sgG9HklFDPCt8VRACaa1VF
X-Copyright: (C) Copyright 2022 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: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Mon, 5 Sep 2022 19:33 UTC

Meredith Montgomery <mmontgomery@levado.to> writes:
....
> d = { "name": "Meredith", "email": "mmontgomery@levado.to" }
> return "The name is {name} and the email is {email}".format(**d)
>--8<---------------cut here---------------end--------------->8---
>Is there a way to do this with f-strings?

I cannot think of anything shorter now than:

eval( 'f"The name is {name} and the email is {email}"', d )

, but with the spaces removed, it's even one character
shorter than the format expression:

eval('f"The name is {name} and the email is {email}"',d)
"The name is {name} and the email is {email}".format(**d)

.

Re: on str.format and f-strings

<8635d5lgmg.fsf@levado.to>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!wV23SPyuRKrhUqTV5ggwqQ.user.46.165.242.91.POSTED!not-for-mail
From: mmontgom...@levado.to (Meredith Montgomery)
Newsgroups: comp.lang.python
Subject: Re: on str.format and f-strings
Date: Mon, 05 Sep 2022 17:18:31 -0300
Organization: Aioe.org NNTP Server
Message-ID: <8635d5lgmg.fsf@levado.to>
References: <868rmxljw2.fsf@levado.to>
<eval-20220905203236@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="10093"; posting-host="wV23SPyuRKrhUqTV5ggwqQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
Cancel-Lock: sha1:z1czyiUMIol8tbyCyZ5quLq6wIM=
X-Notice: Filtered by postfilter v. 0.9.2
 by: Meredith Montgomery - Mon, 5 Sep 2022 20:18 UTC

ram@zedat.fu-berlin.de (Stefan Ram) writes:

> Meredith Montgomery <mmontgomery@levado.to> writes:
> ...
>> d = { "name": "Meredith", "email": "mmontgomery@levado.to" }
>> return "The name is {name} and the email is {email}".format(**d)
>>--8<---------------cut here---------------end--------------->8---
>>Is there a way to do this with f-strings?
>
> I cannot think of anything shorter now than:
>
> eval( 'f"The name is {name} and the email is {email}"', d )
>
> , but with the spaces removed, it's even one character
> shorter than the format expression:
>
> eval('f"The name is {name} and the email is {email}"',d)
> "The name is {name} and the email is {email}".format(**d)
>
> .

Lol. That's brilliant! Thanks very much!

Re: on str.format and f-strings

<22d2ab37-8cfd-41d1-b7aa-7075661c8452n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a05:620a:1432:b0:6be:6c4a:b800 with SMTP id k18-20020a05620a143200b006be6c4ab800mr33575549qkj.578.1662418304057;
Mon, 05 Sep 2022 15:51:44 -0700 (PDT)
X-Received: by 2002:a05:6830:1281:b0:636:d7e9:1906 with SMTP id
z1-20020a056830128100b00636d7e91906mr20565616otp.116.1662418303802; Mon, 05
Sep 2022 15:51:43 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Mon, 5 Sep 2022 15:51:43 -0700 (PDT)
In-Reply-To: <8635d5lgmg.fsf@levado.to>
Injection-Info: google-groups.googlegroups.com; posting-host=93.41.97.142; posting-account=F3H0JAgAAADcYVukktnHx7hFG5stjWse
NNTP-Posting-Host: 93.41.97.142
References: <868rmxljw2.fsf@levado.to> <eval-20220905203236@ram.dialup.fu-berlin.de>
<8635d5lgmg.fsf@levado.to>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <22d2ab37-8cfd-41d1-b7aa-7075661c8452n@googlegroups.com>
Subject: Re: on str.format and f-strings
From: jul...@diegidio.name (Julio Di Egidio)
Injection-Date: Mon, 05 Sep 2022 22:51:44 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1723
 by: Julio Di Egidio - Mon, 5 Sep 2022 22:51 UTC

On Monday, 5 September 2022 at 22:18:58 UTC+2, Meredith Montgomery wrote:
> r...@zedat.fu-berlin.de (Stefan Ram) writes:

> > , but with the spaces removed, it's even one character
> > shorter than the format expression:
> >
> > eval('f"The name is {name} and the email is {email}"',d)
> > "The name is {name} and the email is {email}".format(**d)
>
> Lol. That's brilliant! Thanks very much!

Calling eval for that is like shooting a fly with a cannon.

Besides, this one is even shorter:

f"The name is {d['name']} and the email is {d['email']}"

Julio

Re: on str.format and f-strings

<86czc9jugd.fsf@levado.to>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!wV23SPyuRKrhUqTV5ggwqQ.user.46.165.242.91.POSTED!not-for-mail
From: mmontgom...@levado.to (Meredith Montgomery)
Newsgroups: comp.lang.python
Subject: Re: on str.format and f-strings
Date: Mon, 05 Sep 2022 20:02:42 -0300
Organization: Aioe.org NNTP Server
Message-ID: <86czc9jugd.fsf@levado.to>
References: <868rmxljw2.fsf@levado.to>
<eval-20220905203236@ram.dialup.fu-berlin.de>
<8635d5lgmg.fsf@levado.to>
<22d2ab37-8cfd-41d1-b7aa-7075661c8452n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="61409"; posting-host="wV23SPyuRKrhUqTV5ggwqQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
Cancel-Lock: sha1:s4o3PU0PY7TR6JL93/xlGK/fLng=
X-Notice: Filtered by postfilter v. 0.9.2
 by: Meredith Montgomery - Mon, 5 Sep 2022 23:02 UTC

Julio Di Egidio <julio@diegidio.name> writes:

> On Monday, 5 September 2022 at 22:18:58 UTC+2, Meredith Montgomery wrote:
>> r...@zedat.fu-berlin.de (Stefan Ram) writes:
>
>> > , but with the spaces removed, it's even one character
>> > shorter than the format expression:
>> >
>> > eval('f"The name is {name} and the email is {email}"',d)
>> > "The name is {name} and the email is {email}".format(**d)
>>
>> Lol. That's brilliant! Thanks very much!
>
> Calling eval for that is like shooting a fly with a cannon.

Indeed! But we're not looking for production-quality code. Just an
extreme way to satisfy a silly requirement.

> Besides, this one is even shorter:
>
> f"The name is {d['name']} and the email is {d['email']}"

This doesn't quite satisfy the requeriments. We're trying to specify
only the keys, not the dictionary. (But maybe the requirements did not
say that explicitly. I'd have to look it up again --- it's been
snipped. It's not important. Thanks much for your thoughts!)

Re: on str.format and f-strings

<83b659dd-546b-449a-9545-eef432dbdec6n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:ac8:5710:0:b0:343:5fa9:b707 with SMTP id 16-20020ac85710000000b003435fa9b707mr40533691qtw.192.1662420513583;
Mon, 05 Sep 2022 16:28:33 -0700 (PDT)
X-Received: by 2002:a05:6871:691:b0:126:7f83:bc2c with SMTP id
l17-20020a056871069100b001267f83bc2cmr6014770oao.83.1662420513249; Mon, 05
Sep 2022 16:28:33 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Mon, 5 Sep 2022 16:28:33 -0700 (PDT)
In-Reply-To: <86czc9jugd.fsf@levado.to>
Injection-Info: google-groups.googlegroups.com; posting-host=93.41.97.142; posting-account=F3H0JAgAAADcYVukktnHx7hFG5stjWse
NNTP-Posting-Host: 93.41.97.142
References: <868rmxljw2.fsf@levado.to> <eval-20220905203236@ram.dialup.fu-berlin.de>
<8635d5lgmg.fsf@levado.to> <22d2ab37-8cfd-41d1-b7aa-7075661c8452n@googlegroups.com>
<86czc9jugd.fsf@levado.to>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <83b659dd-546b-449a-9545-eef432dbdec6n@googlegroups.com>
Subject: Re: on str.format and f-strings
From: jul...@diegidio.name (Julio Di Egidio)
Injection-Date: Mon, 05 Sep 2022 23:28:33 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3471
 by: Julio Di Egidio - Mon, 5 Sep 2022 23:28 UTC

On Tuesday, 6 September 2022 at 01:03:02 UTC+2, Meredith Montgomery wrote:
> Julio Di Egidio <ju...@diegidio.name> writes:
> > On Monday, 5 September 2022 at 22:18:58 UTC+2, Meredith Montgomery wrote:
> >> r...@zedat.fu-berlin.de (Stefan Ram) writes:
> >
> >> > , but with the spaces removed, it's even one character
> >> > shorter than the format expression:
> >> >
> >> > eval('f"The name is {name} and the email is {email}"',d)
> >> > "The name is {name} and the email is {email}".format(**d)
> >>
> >> Lol. That's brilliant! Thanks very much!
> >
> > Calling eval for that is like shooting a fly with a cannon.
>
> Indeed! But we're not looking for production-quality code. Just an
> extreme way to satisfy a silly requirement.

Indeed, as far as programming goes, even the premise is
totally nonsensical. Maybe you too better go to the pub?

> > Besides, this one is even shorter:
> >
> > f"The name is {d['name']} and the email is {d['email']}"
>
> This doesn't quite satisfy the requeriments. We're trying to specify
> only the keys, not the dictionary. (But maybe the requirements did not
> say that explicitly. I'd have to look it up again --- it's been
> snipped. It's not important. Thanks much for your thoughts!)

So, here is what you said:

<quote>
It seems to me that str.format is not completely made obsolete by the
f-strings that appeared in Python 3.6.
</quote>

No, of course they can do the same things.

<quote>
My question is whether f-strings can do the
following nice thing with dictionaries that str.format can do:

def f():
d = { "name": "Meredith", "email": "mmont...@levado.to" }
return "The name is {name} and the email is {email}".format(**d)

Is there a way to do this with f-strings?
</quote>

To which I have answered above: and you even save few
characters...

That said, two notes, which is really why I felt compelled
to chime in:

1) saving few characters is always completely and utterly
counter-productive, what you want is readability, if anything;

2) using eval and co. not to type a few characters is plain
abominable.

Never mind, just should anybody be actually interested in
programming.

Have fun,

Julio

Re: on str.format and f-strings

<86v8q1ia42.fsf@levado.to>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!wV23SPyuRKrhUqTV5ggwqQ.user.46.165.242.91.POSTED!not-for-mail
From: mmontgom...@levado.to (Meredith Montgomery)
Newsgroups: comp.lang.python
Subject: Re: on str.format and f-strings
Date: Mon, 05 Sep 2022 22:07:25 -0300
Organization: Aioe.org NNTP Server
Message-ID: <86v8q1ia42.fsf@levado.to>
References: <868rmxljw2.fsf@levado.to>
<eval-20220905203236@ram.dialup.fu-berlin.de>
<8635d5lgmg.fsf@levado.to>
<22d2ab37-8cfd-41d1-b7aa-7075661c8452n@googlegroups.com>
<86czc9jugd.fsf@levado.to>
<83b659dd-546b-449a-9545-eef432dbdec6n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="926"; posting-host="wV23SPyuRKrhUqTV5ggwqQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:WLd0s6bKvevwBWbuM31GC7LjABs=
 by: Meredith Montgomery - Tue, 6 Sep 2022 01:07 UTC

Julio Di Egidio <julio@diegidio.name> writes:

> On Tuesday, 6 September 2022 at 01:03:02 UTC+2, Meredith Montgomery wrote:
>> Julio Di Egidio <ju...@diegidio.name> writes:
>> > On Monday, 5 September 2022 at 22:18:58 UTC+2, Meredith Montgomery wrote:
>> >> r...@zedat.fu-berlin.de (Stefan Ram) writes:
>> >
>> >> > , but with the spaces removed, it's even one character
>> >> > shorter than the format expression:
>> >> >
>> >> > eval('f"The name is {name} and the email is {email}"',d)
>> >> > "The name is {name} and the email is {email}".format(**d)
>> >>
>> >> Lol. That's brilliant! Thanks very much!
>> >
>> > Calling eval for that is like shooting a fly with a cannon.
>>
>> Indeed! But we're not looking for production-quality code. Just an
>> extreme way to satisfy a silly requirement.
>
> Indeed, as far as programming goes, even the premise is
> totally nonsensical. Maybe you too better go to the pub?

It surely isn't precise, but Stefan Ram caught my meaning. It's hard to
be precise. I wanted to avoid having to write things like d['key'].
Stefam Ram provided a solution. I did not care whether it was something
sensible to do in Python from a serious-programming perspective. Thank
you for thoughts anyhow. I appreciate it.

Re: on str.format and f-strings

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: on str.format and f-strings
Date: Wed, 7 Sep 2022 03:57:03 +1000
Lines: 26
Message-ID: <mailman.398.1662487035.20444.python-list@python.org>
References: <868rmxljw2.fsf@levado.to>
<CAPTjJmouzn441Ogxqzse0RPgy-CZbYWz0vcexK2OirF+4zJinQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de 3sLuzIaSQYDlr4cCIyYuhwVa1SdxQ3AI7+Y2ps+nN8mw==
Return-Path: <rosuav@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=mfbJ3KPg;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'def': 0.04; '2022': 0.05;
'pep': 0.07; '"name":': 0.09; 'meant': 0.09; 'url-
ip:151.101.0.223/32': 0.09; 'url-ip:151.101.128.223/32': 0.09;
'url-ip:151.101.192.223/32': 0.09; 'url-ip:151.101.64.223/32':
0.09; '"email":': 0.16; 'chrisa': 0.16; 'from:addr:rosuav': 0.16;
'from:name:chris angelico': 0.16; 'objective': 0.16; 'obsolete':
0.16; 'sept': 0.16; 'url:peps': 0.16; 'wrote:': 0.16; 'python':
0.16; 'says': 0.17; 'to:addr:python-list': 0.20; 'seems': 0.26;
'skip:{ 20': 0.26; 'thinking': 0.28; 'question': 0.32; 'message-
id:@mail.gmail.com': 0.32; 'but': 0.32; "i'm": 0.33; 'there':
0.33; 'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'"the': 0.35; 'following': 0.35; 'from:addr:gmail.com': 0.35;
'received:209.85': 0.37; 'way': 0.38; 'received:209': 0.39;
'received:209.85.208': 0.39; 'wed,': 0.39; 'introduction': 0.61;
'job.': 0.62; 'url-ip:151.101.0/24': 0.62; 'url-
ip:151.101.128/24': 0.62; 'url-ip:151.101.192/24': 0.62; 'url-
ip:151.101.64/24': 0.62; 'email': 0.63; 'meredith': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:from:to:cc:subject:date;
bh=ubDiu27N7KdWuR6p+QXSx9nmlfR9TY3DP9AE+YOt0UM=;
b=mfbJ3KPgjLNGbjo6QM5p0r+nbkLteWYEQOpBGbR8xHGAXJVVkCrJCWoWMM+WBxAKbE
GMSCG8nFqY2/XBBq2hkE9eBxg1E+fM3E3VSs2jgOqfWhh6ukKE2eEzP2sACdf2y3AbEw
p/J16foHA1p5+/IxOyAFYzHO/fglijlHcBfmFsuLG0dKH1A4o8ZDBKXIDJbpUSIqvKuQ
ePiyZKKj2g3hUolAWVIAqxsmGVIU+F92Bc0/9X3nvGY+zA6A8F4HTg52RZ2uFlrgafvM
iWMukoniy1JQ00FQplL/kCpoOoWsiEzMWIIbUna9x79MBUtG+TOAprLU3NQECEHdWNnJ
3Siw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:x-gm-message-state:from:to:cc:subject:date;
bh=ubDiu27N7KdWuR6p+QXSx9nmlfR9TY3DP9AE+YOt0UM=;
b=PYjBH6BQAS7swqIHm1AFSMgT24jCOgLsnSU8bi0xjgMkrkDYS/9HoYyKaTfmoYlJxK
5ffDk5HdLacOwqnQMe5/MANVBLDhfzBBnbZ3oaJcgfCenfFviqb8tdh3XD7LQfp1xIPN
v020XqioZIE9/IMaTu63KE/lk84ihzH3VmjvrDssGSt5IPZ71/1YQDRXJHULdYyHgc3F
0tSW1pArVT70YYvh7Uontq3klrE1/CRyVqmwosZkzhlWtdz+/a2Ahb2xBfP/598N41fO
OKJAgd5OYxuYCeVz/th0UNJrBJT4Gg1rxZWY+04Mg9xDkvjeDAr5byUpXtB1vmKKoT5f
eFfw==
X-Gm-Message-State: ACgBeo0NnA8hioO1EKGUnLhYM53OxdhNK84hstYfNdfq2spikZwhcgmK
XqHcSVdshIJKbHzhMmnkaRllEgNIzy3YXZH5MjMeFJ5e
X-Google-Smtp-Source: AA6agR5NJG5CB+zQCYb52RrtPOJdenn8Ta3f7HgROu5XBytpWMM0pne2sQtxZRV3woH/Q1hezNTNOc1jEl12DScOkew=
X-Received: by 2002:a05:6402:5384:b0:431:6d84:b451 with SMTP id
ew4-20020a056402538400b004316d84b451mr48023140edb.46.1662487034250; Tue, 06
Sep 2022 10:57:14 -0700 (PDT)
In-Reply-To: <868rmxljw2.fsf@levado.to>
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: <CAPTjJmouzn441Ogxqzse0RPgy-CZbYWz0vcexK2OirF+4zJinQ@mail.gmail.com>
X-Mailman-Original-References: <868rmxljw2.fsf@levado.to>
 by: Chris Angelico - Tue, 6 Sep 2022 17:57 UTC

On Wed, 7 Sept 2022 at 03:52, Meredith Montgomery <mmontgomery@levado.to> wrote:
>
> It seems to me that str.format is not completely made obsolete by the
> f-strings that appeared in Python 3.6. But I'm not thinking that this
> was the objective of the introduction of f-strings: the PEP at
>
> https://peps.python.org/pep-0498/#id11
>
> says so explicitly.

Precisely. It was never meant to obsolete str.format, and it does not.

> My question is whether f-strings can do the
> following nice thing with dictionaries that str.format can do:
>
> --8<---------------cut here---------------start------------->8---
> def f():
> d = { "name": "Meredith", "email": "mmontgomery@levado.to" }
> return "The name is {name} and the email is {email}".format(**d)
> --8<---------------cut here---------------end--------------->8---
>
> Is there a way to do this with f-strings?

No. That's not their job. That's str.format's job.

ChrisA

Re: on str.format and f-strings

<86bkrsmieb.fsf@levado.to>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!zGSyq0VTr/yF1LEtjFoB0A.user.46.165.242.91.POSTED!not-for-mail
From: mmontgom...@levado.to (Meredith Montgomery)
Newsgroups: comp.lang.python
Subject: Re: on str.format and f-strings
Date: Tue, 06 Sep 2022 16:07:08 -0300
Organization: Aioe.org NNTP Server
Message-ID: <86bkrsmieb.fsf@levado.to>
References: <868rmxljw2.fsf@levado.to>
<CAPTjJmouzn441Ogxqzse0RPgy-CZbYWz0vcexK2OirF+4zJinQ@mail.gmail.com>
<mailman.398.1662487035.20444.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="14719"; posting-host="zGSyq0VTr/yF1LEtjFoB0A.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
Cancel-Lock: sha1:cxpMzSpIRwnH82QPvBQ7J9VVb+0=
X-Notice: Filtered by postfilter v. 0.9.2
 by: Meredith Montgomery - Tue, 6 Sep 2022 19:07 UTC

Chris Angelico <rosuav@gmail.com> writes:

> On Wed, 7 Sept 2022 at 03:52, Meredith Montgomery <mmontgomery@levado.to> wrote:
>>
>> It seems to me that str.format is not completely made obsolete by the
>> f-strings that appeared in Python 3.6. But I'm not thinking that this
>> was the objective of the introduction of f-strings: the PEP at
>>
>> https://peps.python.org/pep-0498/#id11
>>
>> says so explicitly.
>
> Precisely. It was never meant to obsolete str.format, and it does not.
>
>> My question is whether f-strings can do the
>> following nice thing with dictionaries that str.format can do:
>>
>> --8<---------------cut here---------------start------------->8---
>> def f():
>> d = { "name": "Meredith", "email": "mmontgomery@levado.to" }
>> return "The name is {name} and the email is {email}".format(**d)
>> --8<---------------cut here---------------end--------------->8---
>>
>> Is there a way to do this with f-strings?
>
> No. That's not their job. That's str.format's job.

Chris! So good to see you around here again. Thank you so much for
your input on this.

Re: on str.format and f-strings

<98054152-4827-4a29-a000-553db3255109n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a05:6214:d0b:b0:47b:4d2b:fa53 with SMTP id 11-20020a0562140d0b00b0047b4d2bfa53mr1596083qvh.13.1662533369639;
Tue, 06 Sep 2022 23:49:29 -0700 (PDT)
X-Received: by 2002:a05:6830:1bfa:b0:637:1491:2ac7 with SMTP id
k26-20020a0568301bfa00b0063714912ac7mr880113otb.9.1662533369396; Tue, 06 Sep
2022 23:49:29 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Tue, 6 Sep 2022 23:49:29 -0700 (PDT)
In-Reply-To: <mailman.398.1662487035.20444.python-list@python.org>
Injection-Info: google-groups.googlegroups.com; posting-host=93.41.97.142; posting-account=F3H0JAgAAADcYVukktnHx7hFG5stjWse
NNTP-Posting-Host: 93.41.97.142
References: <CAPTjJmouzn441Ogxqzse0RPgy-CZbYWz0vcexK2OirF+4zJinQ@mail.gmail.com>
<868rmxljw2.fsf@levado.to> <mailman.398.1662487035.20444.python-list@python.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <98054152-4827-4a29-a000-553db3255109n@googlegroups.com>
Subject: Re: on str.format and f-strings
From: jul...@diegidio.name (Julio Di Egidio)
Injection-Date: Wed, 07 Sep 2022 06:49:29 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2420
 by: Julio Di Egidio - Wed, 7 Sep 2022 06:49 UTC

On Tuesday, 6 September 2022 at 19:57:36 UTC+2, Chris Angelico wrote:
> On Wed, 7 Sept 2022 at 03:52, Meredith Montgomery <mmont...@levado.to> wrote:
> >
> > It seems to me that str.format is not completely made obsolete by the
> > f-strings that appeared in Python 3.6. But I'm not thinking that this
> > was the objective of the introduction of f-strings: the PEP at
> >
> > https://peps.python.org/pep-0498/#id11
> >
> > says so explicitly.
> Precisely. It was never meant to obsolete str.format, and it does not.
> > My question is whether f-strings can do the
> > following nice thing with dictionaries that str.format can do:
> >
> > --8<---------------cut here---------------start------------->8---
> > def f():
> > d = { "name": "Meredith", "email": "mmont...@levado.to" }
> > return "The name is {name} and the email is {email}".format(**d)
> > --8<---------------cut here---------------end--------------->8---
> >
> > Is there a way to do this with f-strings?
>
> No. That's not their job. That's str.format's job.

What is not their job, you other resident cretin !?

You fraudulent polluting morons, get extinguished already...

*Plonk*

Julio

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor