• charokol@lemmy.world
    link
    fedilink
    English
    arrow-up
    11
    ·
    3 个月前

    Didn’t think I’d learn anything new in this article, but I never knew about f-string’s self-documenting expression syntax. I’ve been doing it myself like a chump!

  • Caveman@lemmy.world
    link
    fedilink
    arrow-up
    7
    ·
    3 个月前

    I worked in python when f-strings were pretty new. Didn’t realise why you would use anything else. It just reads better.

    • Michal@programming.dev
      link
      fedilink
      arrow-up
      4
      ·
      3 个月前

      Most importantly you can’t use them with translated strings, so it’s not usable for user facing strings unless you don’t care. This limits fstring usefulness a lot in the projects I work on.

  • slag@lemmy.dbzer0.com
    link
    fedilink
    English
    arrow-up
    4
    ·
    3 个月前

    And here I thought f-strings were something that happen when others are forced to read my code.

  • NotSteve_@lemmy.ca
    link
    fedilink
    arrow-up
    2
    ·
    3 个月前

    F-strings and .format() are two features I miss from Python whenever I’m writing stuff in another language. The syntax is just so minimal yet powerful

  • itsathursday@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    3 个月前

    What annoyed me moving from % to format was the loss of “formatting” floats to integers with “{:d}”, now you get a ValueError