🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    String literal (f-string) not supported in uiflow / micropython on M5StickC Plus?

    UIFlow
    2
    7
    3.5k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      erich
      last edited by

      Hi there,

      I have a script which is using string literal, something like:

      name = "john"
      print(f"My name is {name}")

      This code is not working in UIFlow v1 with an M5StickCPlus
      I also tried directly in the REPL and I have the same error.

      Can someone please confirm this is not supported (by UIFlow? Micropython version of the StickCPlus?)

      Thanks
      Eric

      1 Reply Last reply Reply Quote 0
      • P
        pandian.nano
        last edited by pandian.nano

        Hi @erich
        For example:
        name='john'
        print("my name is {0}".format(name))

        E 1 Reply Last reply Reply Quote 0
        • E
          erich @pandian.nano
          last edited by

          @pandian-nano thanks I have already applied this workaround but I was just asking for confirmation that f-string is not supported on the StickCPlus with uiflow1.

          1 Reply Last reply Reply Quote 0
          • P
            pandian.nano
            last edited by

            Hi @erich f-strings don’t support for micropython
            refer this link: https://docs.micropython.org/en/latest/genrst/core_language.html

            0_1697782420373_WeChat Screenshot_20231020141318.png

            E 1 Reply Last reply Reply Quote 0
            • E
              erich @pandian.nano
              last edited by

              @pandian-nano thanks a lot this is very helpful but according to the page you mention your statement saying”fstring is not supported in micropython” is not totally true.
              If you refer to the page you mention you can use FString but not in all scenarios.

              Example;:

              print(f"{x}" "ab") # works
              print("a{}a" f"{x}") # fails

              FString is therefore ‘partially’ supported in micropython

              Thanks anyway, now I have an official explanation ;;)

              1 Reply Last reply Reply Quote 0
              • P
                pandian.nano
                last edited by pandian.nano

                Hi @erich,
                These features(f string) are supported by microPython version v1.17 or higher and uiflow 1 is supported by micropython v1.12, so these features(f string) are not supported.

                0_1698032926638_WeChat Screenshot_20231023114716.png

                E 1 Reply Last reply Reply Quote 0
                • E
                  erich @pandian.nano
                  last edited by

                  @pandian-nano yes you’re right, thanks for the clarification!

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post