codon icon indicating copy to clipboard operation
codon copied to clipboard

String format not supported

Open Michael-F-Ellis opened this issue 3 years ago • 2 comments

% codon --version
0.15.5
% echo 'print("hello")' | codon run
hello
% echo 'print("{}".format(1.23))' | codon run
<stdin>:1:7-24: error: 'str' object has no attribute 'format'

Michael-F-Ellis avatar Mar 11 '23 22:03 Michael-F-Ellis

Thanks for the report -- we do plan to add this in a future version. For now f-strings can be used as a workaround:

x = 1.23
print(f"hello {x:.6f} world")  # hello 1.230000 world

arshajii avatar Mar 12 '23 14:03 arshajii

I've experienced the same issue and appreciate the workaround. I'm hopeful that a permanent fix will be available soon.

JinChengneng avatar Mar 16 '23 02:03 JinChengneng