Toot

Written by Alex Willmer on 2024-12-17 at 14:09

[#]TIL to use a dict-comprehension in an f-string add parens or whitespace #Python

d = {'a': 1, 'b': 2, 'c': 3, 'd': 5, 'e': 6}
f"{({k: v for k, v in d.items() if v % 2})}"

"{'a': 1, 'c': 3, 'd': 5}"

f"{ {k: v for k, v in d.items() if v % 2} }"

"{'a': 1, 'c': 3, 'd': 5}"

=> More informations about this toot | View the thread | More toots from alex@moreati.org.uk

Mentions

Tags

=> View til tag | View python tag

Proxy Information
Original URL
gemini://mastogem.picasoft.net/toot/113668558438673733
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
218.940727 milliseconds
Gemini-to-HTML Time
0.586356 milliseconds

This content has been proxied by September (3851b).