Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

f string float not working

Why am I getting this error with a perfectly valid f string? Sagemath is using Python 3.7.3. I've tried variants a dozen times with the same error.

val = 12.3 print(f'{val:.2f}')

TypeError Traceback (most recent call last) <ipython-input-13-b868ffed9f12> in <module>() 1 val = RealNumber('12.3') 2 ----> 3 print(f'{val:.2f}')

TypeError: unsupported format string passed to sage.rings.real_mpfr.RealLiteral.__format__

f string float not working

Why am I getting this error with a perfectly valid f string? Sagemath f-string? SageMath is using Python 3.7.3. I've tried variants a dozen times with the same error.

val = 12.3
print(f'{val:.2f}')

print(f'{val:.2f}')

TypeError Traceback (most recent call last) <ipython-input-13-b868ffed9f12> in <module>() 1 val = RealNumber('12.3') 2 ----> 3 print(f'{val:.2f}')

print(f'{val:.2f}')

TypeError: unsupported format string passed passed to sage.rings.real_mpfr.RealLiteral.__format__

sage.rings.real_mpfr.RealLiteral.__format__

f string float not working

Why am I getting this error with a perfectly valid f-string? SageMath is using Python 3.7.3. I've tried variants a dozen times with the same error.

val = 12.3
print(f'{val:.2f}')

TypeError                                 Traceback (most recent call last)
<ipython-input-13-b868ffed9f12> in <module>()
      1 val = RealNumber('12.3')
      2 
----> 3 print(f'{val:.2f}')

TypeError: unsupported format string passed
to sage.rings.real_mpfr.RealLiteral.__format__