[Python-Dev] transitioning from % to {} formatting (original) (raw)
Vinay Sajip vinay_sajip at yahoo.co.uk
Wed Oct 7 19:34:02 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 ]
Antoine Pitrou <solipsis pitrou.net> writes:
Vinay Sajip <vinaysajip 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' )
Well of course, but I asked the question in the context of providing an automatic converter from %-format strings to {}-format. At the moment, it doesn't seem like a 100%-faithful automatic conversion is feasible.
Regards,
Vinay Sajip
- Previous message: [Python-Dev] transitioning from % to {} formatting
- Next message: [Python-Dev] transitioning from % to {} formatting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]