A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2018-March/152543.html below:

[Python-Dev] Subtle difference between f-strings and str.format()

[Python-Dev] Subtle difference between f-strings and str.format() [Python-Dev] Subtle difference between f-strings and str.format()Serhiy Storchaka storchaka at gmail.com
Thu Mar 29 14:30:42 EDT 2018
29.03.18 13:17, Jeff Allen пише:
>      '{1} {0}'.format(a(), b()) # E1
> 
>      f'{b()}{a()}'              # E2
> 
> 
> I think I would be very surprised to find b called before a in E1 
> because of the general contract on the meaning of method calls. I'm 
> assuming that's what an AST-based optimisation would do? There's no 
> reason in E2 to call them in any other order than b then a and the 
> documentation tells me they are.

I was going to optimize only formatting with implicit references. '{} 
{}' but not '{1} {0}' and either not '{0} {1}'. This guaranties in-order 
computation and referencing every subexpression only once. I don't have 
a goal of converting every string formatting, but only the most common 
and the most simple ones.

If go further, we will need to add several new AST nodes (like for 
comprehensions).

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4