serhii.net

In the middle of the desert you can say anything you want

01 Feb 2024

Formatting floats as strings inside a list comprehension

Never thought of this, but I can use f-strings inside list comprehensions inside f-strings:

logger.info(f"Stories split into {'/'.join(f'{x:.2f}' for x in actual_split_sizes)}")

(Not that it’s necessarily a good idea to.)

Nel mezzo del deserto posso dire tutto quello che voglio.