F-string syntax with Equals Sign

21 views
Skip to first unread message

Thomas Passin

unread,
May 29, 2024, 10:44:14 AMMay 29
to leo-editor
This has been in Python since version 3.8 but I just learned about it today. It's probably most useful for debugging.  If you end the expression in curly braces with an equals sign, the result will display <expression>=<value> -

>>>some_list = ['a','b','c']
>>>print(f'{some_list=}')
some_list=['a', 'b', 'c']

Jacob Peck

unread,
May 29, 2024, 11:03:57 AMMay 29
to leo-e...@googlegroups.com
Wow, thanks for this.  Can't believe I've missed that.

This will save me hours over the course of a year.

Jake

--
You received this message because you are subscribed to the Google Groups "leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/cf704c8e-076a-4b56-a382-2d18b2282eb2n%40googlegroups.com.

Edward K. Ream

unread,
May 29, 2024, 1:32:56 PMMay 29
to leo-e...@googlegroups.com
On Wed, May 29, 2024 at 9:44 AM Thomas Passin <tbp1...@gmail.com> wrote:
This has been in Python since version 3.8 but I just learned about it today. It's probably most useful for debugging.  If you end the expression in curly braces with an equals sign, the result will display <expression>=<value> -

Thanks for the reminder.

Edward
Reply all
Reply to author
Forward
0 new messages