[Python-3000] string formatting and locals() (WAS: locals(), closures, and IronPython...)

Patrick Maupin pmaupin at gmail.com
Tue Mar 6 21:02:09 CET 2007


Actually, the version checked in to
http://svn.python.org/projects/sandbox/trunk/pep3101 currently will
search both locals() and globals() if no parameters are passed to
format.

It's still a work-in-progress, but has quite a few passing tests, and
builds as an extension module on 2.3, 2.4, and 3.0 (probably also 2.5,
haven't tried it).  The file pep_differences.txt shows the current
differences between that and the original PEP.

Regards,
Pat


On 3/6/07, Steven Bethard <steven.bethard at gmail.com> wrote:
> On 3/6/07, Georg Brandl <g.brandl at gmx.net> wrote:
> > While we're at it: I've had a thought about string formatting in Py3k.
> > Suppose you do something like
> >
> > name = "He"
> > what = "Ex-Parrot"
> > print "{name} is an {what}".format(name=name, what=what)
> >
> > it seems a bit too verbose. Why not have format() without any arguments
> > default to format(**locals())?
>
> Since format() is just a normal string method, isn't that going to
> require some frame hackery?
>
> 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
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe: http://mail.python.org/mailman/options/python-3000/pmaupin%40gmail.com
>


More information about the Python-3000 mailing list