[Python-3000] Implementing % formatting in terms of str.format()
Steven Bethard
steven.bethard at gmail.com
Sat Apr 12 21:01:58 CEST 2008
On Sat, Apr 12, 2008 at 12:26 PM, Georg Brandl <g.brandl at gmx.net> wrote:
> Steven Bethard schrieb:
>
> > 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.
>
> Please don't -- a Py3k warning makes no sense if the feature isn't really
> going away in Py3k. Py3k warnings really should only warn about things
> that are going to break in 3.0.
My understanding is that we'd break % string formatting in Py3k if we
could. The only reason we won't is that it's not generally possible to
write a 2to3 fixer. So while it won't actually break, I think
conveying our intention to break it (using a -3 warning) wouldn't be
unreasonable.
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