🤖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?

    Scheduled Pinned Locked Moved UIFlow
    7 Posts 2 Posters 6.1k Views 2 Watching
    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 Offline
      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 Offline
        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 Offline
          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 Offline
            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 Offline
              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 Offline
                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 Offline
                  erich @pandian.nano
                  last edited by

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

                  1 Reply Last reply Reply Quote 0

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  • First post
                    Last post