[Python-Dev] transitioning from % to {} formatting (original) (raw)
Vinay Sajip vinay_sajip at yahoo.co.uk
Thu Oct 1 09:07:52 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 ]
Brett Cannon <brett python.org> writes:
As for the PercentMessage/BraceMessage, I would make sure that you just simply take the string format and simply apply the arguments later to cut down on the amount of parentheses butting up against each other:
logger.debug(BraceMessage("The {} is {}"), "answer", 42)
.
The problem with that is that BraceMessage.str() wouldn't know what arguments to use to produce the message.
cost of wrapping all strings for a while. I suspect most people will simply import the wrapping class and give it some short name like people do with gettext.
Yes,
logger.debug(__("The {} is {}", "answer", 42))
isn't ideal but perhaps liveable with. And hopefully with a decent editor, the paren-butting annoyance will be minimized.
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 ]