[Python-3000] Implementing % formatting in terms of str.format()
Steven Bethard
steven.bethard at gmail.com
Sat Apr 12 19:49:18 CEST 2008
On Sat, Apr 12, 2008 at 8:26 AM, <skip at pobox.com> wrote:
>
> Nick> That's exactly the problem though - while a 2to3 fixer can be
> Nick> written for a tiny subset of formatting calls (those that meet the
> Nick> constraints you gave)...
>
> In my personal experience, either the LHS will be a string literal or the
> RHS will be locals(), globals() or a tuple. Yes, you will have a hard, if
> not impossible, time with the general x % y. Still, I think a fixer that
> only addresses the "tiny subset" would go a long ways to converting existing
> code. For the rest it could insert special comments so the programmer can
> grep for the problematic cases.
Rather than inserting special comments, why don't we just introduce a
-3 warning for using % string formatting? Then, you can use 2to3 to
convert as much as it can, and you can use the -3 warning to identify
any other places you're using % string formatting and fix them by
hand. Adding such a -3 warning shouldn't be much more than a couple of
lines at the beginning of stringobject.c:PyString_Format.
Steve
--
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
--- Bucky Katt, Get Fuzzy
More information about the Python-3000
mailing list