How to use f-string in mojo

I want to write a ppm file in mojo using f-string pattern. e.g., thingss like: out.write(f"P3\n{pic.size_X} {pic.size_Y}\n255\n") out.write(f"{clamp(round(r))} {clamp(round(g))} {clamp(round(b))} ") etc. But I can't use f-strings in mojo. Plus if I try to do like this: out.write("P3\n",picture.size_X, picture.size_Y,"\n255\n") It gives me the following error: error: no matching function in call to 'write': out.write("P3\n",picture.size_X, picture.size_Y,"\n255\n") ~~~^~~~~~~~~~~ /home/talha/Desktop/mojo/jpeg/C-code/Mojo/main.mojo:1:1: note: candidate not viable: callee expects 2 arguments, but 5 were specified Can someone please help me how to write files?
3 Replies
gryznar
gryznar11mo ago
Mojo currently does not support fstrings. See: https://docs.modular.com/mojo/roadmap.html
Modular Docs - Mojo🔥 roadmap & sharp edges
A summary of our Mojo plans, including upcoming features and things we need to fix.
Deleted User
Deleted User10mo ago
Stack Overflow
How to do string interpolation (formatting) with Mojo?
I couldn't find how to do string formatting in Mojo in the docs. I have tried the common Python methods (str.format(), f-strings, % placeholder), but nothing worked out so far. I know Mojo is still a
Deleted User
Deleted User10mo ago
this guy wrote a good implementation to get around it
Want results from more Discord servers?
Add your server