[Python-ideas] Should Python have user-defined constants?
elazarg at gmail.com
Tue Nov 21 13:05:17 EST 2017
בתאריך יום ג׳, 21 בנוב׳ 2017, 19:36, מאת Chris Barker <
chris.barker at noaa.gov>:
And what's the use-case, really? beyond the use case for all sorts of
> static typing...
I don't understand the question. The use case was explained before - people
want to have better ways to reason about their programs. Statically. Why
dismiss it as a non-usecase? It's helpful for both tools and humans.
It was mentioned that there are related conventions in Python. Good point.
But they are not as strong as the "convention" that tuples and strings
cannot change, and this is useful in reasoning about code - in
understanding the program, essentially.
When I read "final int x = 5;" in Java, I don't have to think about it
anymore - it's 5. When I read "X = 5" in Python, it might be a constant,
but it might also be a misnomer, or something that used to be a constant,
or a class reassigned. I still have to watch whether it will be changed,
intentionally or accidentally, by this or other module. It does not even
communicate intention in an unambiguous way.
In my opinion, the inability to control mutation in Python is the biggest
readability issue of the language (thank god monkey-patching is
I see why the proposal can be rejected, but I don't understand the "you
don't gain anything" responses. There are significant gains there.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas