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

Created on 2008-04-08 19:38 by dangyogi, last changed 2008-05-06 13:21 by eric.smith.

Messages
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) 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 '}',
    etc.).
""" <http://www.python.org/dev/peps/pep-3101>;


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:
http://docs.python.org/dev/3.0/library/string.html#formatstrings 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.
History
Date User Action Args
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