[Python-Dev] transitioning from % to {} formatting (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Wed Sep 30 19:01:35 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 ]
James Y Knight <foom fuhm.net> writes:
The user could write either: logging.Formatter("%(asctime)s - %(name)s - %(level)s - %(msg)s") (as always -- that can't be changed without a long deprecation period), or: logging.Formatter(newstyleformatstr("{asctime} - {name} - {level} - {msg}")
Why not allow logging.Formatter to take a callable, which would in turn call the callable with keyword arguments?
Therefore, you could write: logging.Formatter("{asctime} - {name} - {level} - {msg}".format)
and then: logging.critical(name="Python", msg="Buildbots are down")
All this without having to learn about a separate "compatibility wrapper object".
Regards
Antoine.
- Previous message: [Python-Dev] transitioning from % to {} formatting
- Next message: [Python-Dev] transitioning from % to {} formatting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]