A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2009-October/092570.html below:

[Python-Dev] transitioning from % to {} formatting

[Python-Dev] transitioning from % to {} formatting [Python-Dev] transitioning from % to {} formattingVinay Sajip vinay_sajip at yahoo.co.uk
Mon Oct 5 12:16:53 CEST 2009
MRAB <python <at> mrabarnett.plus.com> writes:

>  >>> "{0:#08x}".format(0x1234)
> '0x001234'

Good call, but here's another case:

>>> "%#o" % 0x1234
'011064'

I don't see how to automatically convert the "%#o" spec, though of course there
are ways of fudging it. The obvious conversion doesn't give the same value:

>>> "{0:#o}".format(0x1234)
'0o11064'

I couldn't see a backward-compatibility mode for str.format generating just a
leading "0" for octal alternative format (the C style) as opposed to "0o".

Regards,

Vinay Sajip

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4