[Python-Dev] transitioning from % to {} formatting (original) (raw)
James Y Knight foom at fuhm.net
Thu Oct 1 17:42:38 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 ]
On Oct 1, 2009, at 9:11 AM, Paul Moore wrote:
This seems to me to be almost the same as the previous suggestion of having a string subclass:
class BraceFormatter(str): def mod(self, other): # Needs more magic here to cope with dict argument return self.format(*other) __ = BraceFormatter_ logger.debug(("The {0} is {1}"), "answer", 42)_
I'd rather make that:
class BraceFormatter: def init(self, s): self.s = s def mod(self, other): # Needs more magic here to cope with dict argument return s.format(*other)
__ = BraceFormatter
That is, not a string subclass. Then if someone attempts to mangle
it, or use it for anything but %, it fails loudly.
James
- Previous message: [Python-Dev] transitioning from % to {} formatting
- Next message: [Python-Dev] transitioning from % to {} formatting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]