[issue43695] Improve `=` in f-strings

2021-04-02 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I think there is a slim chance of implementing similar feature in future. If once we implement pytest-like asserts, we will need to add special expression evaluator which saves all intermediate results of subexpressions and pass them to some hook

[issue43695] Improve `=` in f-strings

2021-04-01 Thread Eric V. Smith
Eric V. Smith added the comment: I'm going to close this. I agree with Serhiy that it's pushing f-strings too far. If you really want to pursue this, you'll need to specify the semantics much more clearly, and then bring it up on the python-ideas mailing list. But I don't want to give you

[issue43695] Improve `=` in f-strings

2021-04-01 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I think it goes too far. It was initially designed as a simple for implementation and use feature which covers a large amount of use cases of using f-strings for debugging. You propose to add syntactically a new postfix operator which is valid only in

[issue43695] Improve `=` in f-strings

2021-04-01 Thread Eric V. Smith
Eric V. Smith added the comment: I don't see how this would be possible in general. What would you do with a function call that has side effects? f'{a()+b+c=}' ? You'd end up calling a() twice, or inventing your own expression evaluator. -- nosy: +eric.smith

[issue43695] Improve `=` in f-strings

2021-04-01 Thread wyz23x2
wyz23x2 added the comment: Well, it's: >>> f'{a+b-c=?}' # Suffix `=` to apply to all? 20+40-10=50 P.S. When will the bug tracker enable message editing? -- ___ Python tracker

[issue43695] Improve `=` in f-strings

2021-04-01 Thread wyz23x2
New submission from wyz23x2 : In Python 3.8, `=` was added into f-strings: >>> a, b, c = 20, 40, 10 >>> f'{a+b-c=}' a+b-c=50 But if `20+40-10` is wanted, this needs to be written: >>> f'{a}+{b}-{c}={a+b-c}' 20+40-10=50 So something could be added. For example, `?` (this doesn't mean I recommend