on str.format and f-strings

Meredith Montgomery mmontgomery at levado.to
Mon Sep 5 21:07:25 EDT 2022


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

> On Tuesday, 6 September 2022 at 01:03:02 UTC+2, Meredith Montgomery wrote:
>> Julio Di Egidio <ju... at diegidio.name> writes: 
>> > On Monday, 5 September 2022 at 22:18:58 UTC+2, Meredith Montgomery wrote: 
>> >> r... at 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.


More information about the Python-list mailing list