Javascript (ES6) has 'let' and 'const' for mutable and constant variables, respectively.
When programming in JS, I find myself aggressively aiming for as little 'let' and as much 'const' as reasonably possible, since reasoning about constants is much easier than about variables. In this context, 'const' is used as a marker, a runtime checker, and, with proper tooling (IDE or linter), a coding-time reminder to differentiate between these two fundamental behaviours. I'm not +1 on introducing this idea to Python yet, but not -1 either - this deserves some discussion, if this has not been discussed already. Cheers, S. On Tue, Nov 21, 2017 at 9:13 AM, Steven D'Aprano <[email protected]> wrote: > On Tue, Nov 21, 2017 at 02:38:45AM -0500, Joseph Jevnik wrote: > > > How is that different from "pi = 3.14"? > > pi = 3.14 > pi = 5 > print(pi) > # prints 5 > > let pi = 3.14 > pi = 5 > # raises an exception > > > > -- > Steve > _______________________________________________ > Python-ideas mailing list > [email protected] > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > -- Stefane Fermigier - http://fermigier.com/ - http://twitter.com/sfermigier - http://linkedin.com/in/sfermigier Founder & CEO, Abilian - Enterprise Social Software - http://www.abilian.com/ Chairman, Free&OSS Group / Systematic Cluster - http://www.gt-logiciel-libre.org/ Co-Chairman, National Council for Free & Open Source Software (CNLL) - http://cnll.fr/ Founder & Organiser, PyData Paris - http://pydata.fr/ --- “You never change things by fighting the existing reality. To change something, build a new model that makes the existing model obsolete.” — R. Buckminster Fuller
_______________________________________________ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
