This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: "{ +(}".format(**{' +(': 44}) should produce ValueError: invalid identifier, ' +(' in format
Type: behavior Stage:
Components: Interpreter Core Versions: Python 3.0
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: eric.smith Nosy List: belopolsky, dangyogi, eric.smith
Priority: normal Keywords:

Created on 2008-04-08 19:38 by dangyogi, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg65209 - (view) Author: Bruce Frederiksen (dangyogi) Date: 2008-04-08 19:38
Format strings are documented to only allow identifiers or integers as
the field_name, but allow almost anything.

Python 3.0a3
msg65265 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2008-04-09 21:23
This is a feature explained in PEP 3101:

    Implementation note: The implementation of this proposal is
    not required to enforce the rule about a simple or dotted name
    being a valid Python identifier.  Instead, it will rely on the
    getattr function of the underlying object to throw an exception if
    the identifier is not legal.  The str.format() function will have
    a minimalist parser which only attempts to figure out when it is
    "done" with an identifier (by finding a '.' or a ']', or '}',
""" <>

Why is that a problem for you?
msg65404 - (view) Author: Bruce Frederiksen (dangyogi) Date: 2008-04-12 16:38
I was reading the 3.0 documentation: which
indicated that an identifier was required.  I was unaware of the
implementation note in the PEP.

They only issue remaining is that for the example in the title of this
issue, "{ +(}".format(**{' +(': 44}), no error is generated.  I agree
that this is a nit and presumably the will of the community reviewing
the PEP, so agree to having the issue rejected.

I would reject it myself, but am unable to do so...

Thank you for pointing out the PEP to me.
msg67122 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2008-05-20 11:34
After discussing this with Talin, we've decided this is "works as
designed".  The problem, if any, is that **{' +(': 44} is allowed as a
parameter.  I think that perhaps that should be an error, but I haven't
had time to research if this is already a known issue.
msg67123 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2008-05-20 11:41
I should have been clearer.  By "The problem, if any, is that **{' +(':
44} is allowed as a parameter", I meant in general, for all
function/method calls.  It's not an issue that's restricted to str.format().
Date User Action Args
2022-04-11 14:56:33adminsetgithub: 46850
2008-05-20 11:41:57eric.smithsetmessages: + msg67123
2008-05-20 11:35:57eric.smithsetstatus: open -> closed
resolution: rejected
messages: + msg67122
2008-05-06 13:21:20eric.smithsetassignee: eric.smith
nosy: + eric.smith
2008-04-12 16:38:36dangyogisetmessages: + msg65404
2008-04-09 21:23:35belopolskysetnosy: + belopolsky
messages: + msg65265
2008-04-08 19:38:42dangyogicreate