[Python-Dev] PEP 3101 implementation vs. documentation

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Jun 12 01:29:23 CEST 2011


Ben Wolfson wrote:
> You can't have an internal replacement
> field in this part of the replacement field, so '{' can always safely
> be assumed to be Just a Brace and not the start of a replacement
> field, regardless of whether it's doubled,

I'm worried that the rules in this area are getting too
complicated for a human to follow. If braces are allowed
as plain data between square brackets and/or vice versa,
it's going to be a confusing mess to read, and there will
always be some doubt in the programmer's mind as to whether
they have to be escaped somehow or not.

I'm inclined to think that any such difficult cases should
simply be disallowed. If the docs say an identifier is required
someplace, the implementation should adhere strictly to that.

It's not *that* hard to parse an indentifier properly, and
IMO any use case that requires putting arbitrary characters
into an item selector is abusing the format mechanism and
should be redesigned to work some other way.

-- 
Greg


More information about the Python-Dev mailing list