[Python-Dev] transitioning from % to {} formatting (original) (raw)
Paul Moore p.f.moore at gmail.com
Mon Oct 5 10:41:08 CEST 2009
- Previous message: [Python-Dev] transitioning from % to {} formatting
- Next message: [Python-Dev] transitioning from % to {} formatting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2009/10/5 Vinay Sajip <vinay_sajip at yahoo.co.uk>:
Raymond Hettinger <python rcn.com> writes:
We should get one written. ISTM, every %-formatting string is directly translatable to an equivalent {}-formatting string. I'm not sure you can always get equivalent output from the formatting, though. For example:
"%0#8x" % 0x1234 '0x001234' "{0:0>#8x}".format(0x1234) '000x1234'
Someone please tell me if there's a better {}-format string which I've missed!
Ironically,
"0x{0:0>6x}".format(0x1234) '0x001234'
ignoring the # modifier altogether...
Paul.
- Previous message: [Python-Dev] transitioning from % to {} formatting
- Next message: [Python-Dev] transitioning from % to {} formatting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]