[Python-3000] Please don't kill the % operator...

Guido van Rossum guido at python.org
Fri Aug 17 17:42:56 CEST 2007


I think you should just disallow {...} for the start of the variable
reference. I.e. {0.{1}} is okay, but {{1}} is not.

On 8/17/07, Eric Smith <eric+python-dev at trueblade.com> wrote:
> Ron Adam wrote:
> >
> > Martin v. Lo"wis wrote:
> >> Bill Janssen schrieb:
> >>>> I think most of these points are irrelevant. The curly braces are not
> >>>> just syntactic sugar, at least the opening brace is not; the digit
> >>>> is not syntactic sugar in the case of message translations.
> >>> Are there "computation of matching braces" problems here?
> >> I don't understand: AFAIK, the braces don't nest, so the closing
> >> brace just marks the end of the place holder (which in the printf
> >> format is defined by the type letter).
>
> > So expressions like the following might be difficult to spell.
> >
> >       '{{foo}{bar}}'.format(foo='FOO', bar='BAR', FOOBAR = "Fred")
> >
> > This would probably produce an unmatched brace error on the first '}'.
>
> Ah, I see.  I hadn't thought of that case.  You're correct, it gives an
> error on the first '}'.  This is a case where allowing whitespace would
> solve the problem, sort of like C++'s "< <" template issue (which I
> think they've since addressed).  I'm not sure if it's worth doing, though:
>
> '{ {foo}{bar} }'.format(foo='FOO', bar='BAR', FOOBAR = "Fred")
>
> On second thought, that won't work.  For example, this currently doesn't
> work:
> '{0[{foo}{bar}]}'.format({'FOOBAR': 'abc'}, foo='FOO', bar='BAR')
> KeyError: 'FOO'
>
> I can't decide if that's a bug or not.
>
> Eric.
>
>
> _______________________________________________
> 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/guido%40python.org
>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list