3 ms·
> An early version of this PEP proposed that interpolations should be lazily evaluated. [...] This was rejected for several reasons [...] Bummer. This could ha
by notpushkin 2y ago
> An early version of this PEP proposed that interpolations should be lazily evaluated. [...] This was rejected for several reasons [...]
Bummer. This could have been so useful:
statement_endpoint: Final = "/api/v2/accounts/{iban}/statement"
(Though str.format isn’t really that bad here either.)
- LordShredda 2y agoWould be useful in that exact case, but would be an absolute nightmare to debug, on par with using global variables as function inputs
- notpushkin 2y agoYeah, to be honest, every time this comes to mind I think “wow, this would be really neat!”, then realize just using .format() explicitly is way easier to read.
- nhumrich 2y agoThere was a very very long discussion on this point alone, and there are a lot of weird edge cases, and led to weird syntax things. The high level idea was to defer lazy eval to a later PEP if its still needed enough. There are a lot of existing workarounds in the discussions if you are interested enough in using it, such as using lambdas and t-strings together.
- o11c 2y agoI do think that people are far too hesitant to bind member functions sometimes: statement_endpoint: Final = "/api/v2/accounts/{iban}/statement".format (it's likely that typecheckers suck at this like they suck at everything else though)