A RetroSearch Logo

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

Search Query:

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

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

[Python-Dev] transitioning from % to {} formatting [Python-Dev] transitioning from % to {} formattingAntoine Pitrou solipsis at pitrou.net
Wed Oct 7 19:21:53 CEST 2009
Vinay Sajip <vinay_sajip <at> yahoo.co.uk> writes:
> 
> >>> "%0#8x" % 0x1234
> '0x001234'
> >>> "{0:0>#8x}".format(0x1234)
> '000x1234'

Apart from the sheer unreadability of the {}-style format string, the result 
looks rather unexpected from a human being's point of view.

(in those situations, I would output the 0x manually anyway, such as:
>>> "0x%06x" % 0x1234
'0x001234'
>>> "0x{:06x}".format(0x1234)
'0x001234'
)

Regards

Antoine.


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