<div dir="ltr">ISTM that using the already widely used convention of ALL_CAPS for constants is plenty for linters to warn about rebinding names.<div><br></div><div>Python believes "we're all adults here" after all. So even though it's worth *warning* users if BUFFER_LIMIT gets redefined, there can be reasons between consenting adults for doing so when you know what you are doing.</div><div><br></div><div>It feels similar to the fact that I *can* call:</div><div><br></div><div> instance._Klass__secret()</div><div><br></div><div>But the spelling suggests a strong recommendation to use a more public API. Exact same story with redefining an implied constant.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 21, 2017 at 7:47 AM, Victor Stinner <span dir="ltr"><<a href="mailto:victor.stinner@gmail.com" target="_blank">victor.stinner@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">2017-11-21 7:33 GMT+01:00 Saeed Baig <<a href="mailto:saeedbaig616@icloud.com">saeedbaig616@icloud.com</a>>:<br>
> Hey guys I am thinking of perhaps writing a PEP to introduce user-defined<br>
> constants to Python. Something along the lines of Swift’s “let” syntax (e.g.<br>
> “let pi = 3.14”).<br>
<br>
</span>If you want to work on a PEP, you will have to write a strong<br>
rationale for it :-)<br>
<span class=""><br>
> Do you guys think it would be a good idea? Why or why not? Do you think<br>
> there’s a better way to do it? I’d like to know what others think about this<br>
> idea before making any formal submission (I’ve already posted this same<br>
> question on python-list, but I just wanted to gauge opinion here too).<br>
<br>
</span>Python has different kinds of namespaces: module globals, class<br>
attributes, function local variables, etc.<br>
<br>
The <a href="https://github.com/fijal/quill" rel="noreferrer" target="_blank">https://github.com/fijal/quill</a> programming language looks like<br>
Python but makes module globals *mapping* "immutable": setattr(module,<br>
'var', new_value). Only the mapping is immutable, a value can be<br>
mutable. I guess that the motivation here is to help the optimizer to<br>
emit more efficient code.<br>
<br>
See also previous attempts:<br>
<br>
"PEP 416 -- Add a frozendict builtin type"<br>
<a href="https://www.python.org/dev/peps/pep-0416/" rel="noreferrer" target="_blank">https://www.python.org/dev/<wbr>peps/pep-0416/</a><br>
=> my motivation was to develop a sandbox for Python<br>
<br>
"PEP 351 -- The freeze protocol"<br>
<a href="https://www.python.org/dev/peps/pep-0351/" rel="noreferrer" target="_blank">https://www.python.org/dev/<wbr>peps/pep-0351/</a><br>
=> I guess that the main motivation was to previous programming<br>
mistakes, misuse of an API<br>
<br>
The question is if you only want to have a technical solution to<br>
prevent modification of module globals, or if you would like to<br>
advertize that a variable is constant and use it somehow.<br>
<span class="HOEnZb"><font color="#888888"><br>
Victor<br>
</font></span><div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Keeping medicines from the bloodstreams of the sick; food <br>from the bellies of the hungry; books from the hands of the <br>uneducated; technology from the underdeveloped; and putting <br>advocates of freedom in prisons. Intellectual property is<br>to the 21st century what the slave trade was to the 16th.<br></div>
</div>