Python json library is of simple use but there's this problem:

sage: import json
sage: json.dumps( {"a": 1.8} )
...produce an error because:
sage: x = 1.8
sage: type(x)
<type 'sage.rings.real_mpfr.RealLiteral'>

Should one do the "type cast" below for every int or float when using
sage ?

sage: type(float(x))
<type 'float'>
sage: json.dumps( {"a": float(x)} )
'{"a": 1.8}'

Any easier way ?

Thank you,
Pedro

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to