Is there a way to use new Python string
formatting<http://docs.python.org/library/string.html> in
Sage without disabling the preparser?
For now I get the following:
sage: "int: {0:d}; hex: {0:#x}; oct: {0:#o}; bin: {0:#b}".format(42)
> ---------------------------------------------------------------------------
> ValueError Traceback (most recent call last)
> /home/zoresvit/devel/ciphering/algebraic/<ipython console> in <module>()
> ValueError: Unknown format code 'd' for object of type 'str'
If the preparser is off, everything works:
sage: preparser(False)
> sage: "int: {0:d}; hex: {0:#x}; oct: {0:#o}; bin: {0:#b}".format(42)
> 'int: 42; hex: 0x2a; oct: 0o52; bin: 0b101010'
I'm using Sage 4.8:
$ sage --version
> Sage Version 4.8, Release Date: 2012-01-20
> $ sage -python
> Python 2.6.4 (r264, Jan 20 2012, 00:16:31)
> [GCC 4.4.3] on linux2
Thanks.
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org