<div dir="ltr"><div><i>locals </i>and <i>globals</i> are documented as dictionaries
 (for example exec's documentation states that "
  If only <em>globals</em> is provided, it must be a dictionary") 

 but __dict__ is described as " [a] dictionary or other mapping object".</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, 7 Oct 2018 at 19:38, Chris Barker via Python-Dev <<a href="mailto:python-dev@python.org">python-dev@python.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr">On Fri, Oct 5, 2018 at 3:01 PM Brett Cannon <<a href="mailto:brett@python.org" target="_blank">brett@python.org</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I'm also fine with saying that keys in **kwargs that are not proper identifiers is an implementation detail.<br></div></blockquote><div><br></div><div>It's not just **kwargs -- you can also use arbitrary names with setattr() / getattr() :<br><br>In [6]: setattr(foo, "4 not an identifier", "this works")<br><br>In [7]: getattr(foo, "4 not an identifier")<br>Out[7]: 'this works'</div><div><br></div><div>Which brings up a question I've had for years -- is the fact that cPython uses a regular old dict for namespaces (and **kwargs) part of the language spec, or an implementation detail?</div><div><br></div><div>I would say that for the get/setattr() example, it is kinda handy when you want to use a class instance to model some external data structure that may have different identifier rules. Though I tend to think that's mingling data and code too much.</div><div><br></div><div>-CHB</div><div><br></div> <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"></div><div class="gmail_quote"><div dir="ltr">On Thu, 4 Oct 2018 at 02:20, Serhiy Storchaka <<a href="mailto:storchaka@gmail.com" target="_blank">storchaka@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">04.10.18 11:56, Steven D'Aprano пише:<br>
> While keyword arguments have to be identifiers, using **kwargs allows<br>
> arbitrary strings which aren't identifiers:<br>
> <br>
> py> def spam(**kwargs):<br>
> ....     print(kwargs)<br>
> ....<br>
> py> spam(**{"something arbitrary": 1, '\n': 2})<br>
> {'something arbitrary': 1, '\n': 2}<br>
> <br>
> <br>
> There is some discussion on Python-Ideas on whether or not that<br>
> behaviour ought to be considered a language feature, an accident of<br>
> implementation, or a bug.<br>
> <br>
> Can we get some guidence on this please?<br>
<br>
This is an implementation detail. Currently CPython doesn't ensure that <br>
keyword argument names are identifiers for performance reasons. But this <br>
can be changed in future versions or in other implementations.<br>
<br>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/brett%40python.org" rel="noreferrer" target="_blank">https://mail.python.org/mailman/options/python-dev/brett%40python.org</a><br>
</blockquote></div>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/chris.barker%40noaa.gov" rel="noreferrer" target="_blank">https://mail.python.org/mailman/options/python-dev/chris.barker%40noaa.gov</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="m_167175234268850197gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            (206) 526-6959   voice<br>7600 Sand Point Way NE   (206) 526-6329   fax<br>Seattle, WA  98115       (206) 526-6317   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div></div></div>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/jmcs%40jsantos.eu" rel="noreferrer" target="_blank">https://mail.python.org/mailman/options/python-dev/jmcs%40jsantos.eu</a><br>
</blockquote></div>