<div dir="ltr">I'd say let sleeping dogs lie.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 31, 2017 at 3:52 AM, Eric V. Smith <span dir="ltr"><<a href="mailto:eric@trueblade.com" target="_blank">eric@trueblade.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">If I had it to do over again, I’d implement it more strictly and only allow chars that are valid in identifiers. <div><br></div><div>But see <a href="https://bugs.python.org/issue31907" target="_blank">https://bugs.python.org/<wbr>issue31907</a> for a case that is currently valid and would break if we changed how it worked. </div><div><br></div><div>I’m not sure it’s worth the churn of deprecating this and eventually making it illegal. <br><br><div id="m_6108212886325592715AppleMailSignature">--<div>Eric.</div></div><span class=""><div><br>On Oct 31, 2017, at 6:37 AM, Serhiy Storchaka <<a href="mailto:storchaka@gmail.com" target="_blank">storchaka@gmail.com</a>> wrote:<br><br></div></span><blockquote type="cite"><div><span class=""><span>According to the specification of format string syntax [1] (I meant str.format(), not f-strings), both argument name and attribute name must be Python identifiers.</span><br><span></span><br><span>But the current implementation is more lenient and allow arbitrary sequences of characters while they don't contain '.', '[', ']', '{', '}', ':', '!'.</span><br><span></span><br><span>>>> '{#}'.format_map({'#': 42})</span><br><span>'42'</span><br><span>>>> import types</span><br><span>>>> '{0.#}'.format(types.<wbr>SimpleNamespace(**{'#': 42}))</span><br><span>'42'</span><br><span></span><br><span>This can be confusing due to similarity with the format string syntaxes in str.format() and f-strings.</span><br><span></span><br><span>>> name = 'abc'</span><br><span>>>> f'{name.upper()}'</span><br><span>'ABC'</span><br><span>>>> '{name.upper()}'.format(name='<wbr>abc')</span><br><span>Traceback (most recent call last):</span><br><span>  File "<stdin>", line 1, in <module></span><br><span>AttributeError: 'str' object has no attribute 'upper()'</span><br><span></span><br><span>If accept only identifiers, we could produce more specific error message.</span><br><span></span><br><span>Is there a bug in the documentation or in the implementation?</span><br><span></span><br><span>[1] <a href="https://docs.python.org/3/library/string.html#format-string-syntax" target="_blank">https://docs.python.org/3/<wbr>library/string.html#format-<wbr>string-syntax</a></span><br><span></span><br><span>______________________________<wbr>_________________</span><br><span>Python-Dev mailing list</span><br><span><a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a></span><br><span><a href="https://mail.python.org/mailman/listinfo/python-dev" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-dev</a></span><br></span><span>Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/eric%2Ba-python-dev%40trueblade.com" target="_blank">https://mail.python.org/<wbr>mailman/options/python-dev/<wbr>eric%2Ba-python-dev%<wbr>40trueblade.com</a></span><br></div></blockquote></div></div><br>______________________________<wbr>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/guido%40python.org" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/options/python-dev/<wbr>guido%40python.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div>