Prev: can you say it please
Next: can python do this?
From: Vinay Sajip on 10 Dec 2009 13:03 On Dec 3, 12:12 am, Terry Reedy <tjre...(a)udel.edu> wrote: > At the moment (3.1) there are, unfortunately, library packages that > require % for formatting (logging, I believe, for one). There has been > discussion on adding a new option for 3.2, but I do not know what will > happen. Depends on whether you want to be absolutely complete. I > strictly use .format when I can, which so far is always. Logging uses %-style formatting because that was all that was available at the time it was written. A frequent complaint from some quarters is about the overhead of logging, and so I'm not sure it's a good idea to switch over from %-formatting to str.format just for the sake of it, unless a way can be found which avoids the problems of lower performance and backwards compatibility (e.g. a foolproof %- string to {} converter, which I've had a stab at, but which cannot be achieved without changes to the {} code, e.g. to allow old-style octal constants). As far as logging is concerned I'll be periodically looking to see if moving over to the new format without performance/ backwards compatibility compromises is feasible, and when it is I'll adopt the new format. For now, AFAIK, people who are determined to use the {}-format can do so by subclassing logging.Formatter and by passing in message classes which convert format-string and args to final message. It's a one-time cost they'd incur (to write the relevant subclasses) which could be used on multiple projects. Regards, Vinay Sajip |