[Python-ideas] Should Python have user-defined constants?

Sven R. Kunze srkunze at mail.de
Tue Nov 21 17:11:27 EST 2017


On 21.11.2017 19:05, אלעזר wrote:
> 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.

Then type annotations are for them.

But please don't clutter the core language with this.

> 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.

What about using real-world names instead of X? That could make the 
intentions crystal clear if you ask me.


Cheers,
Sven


PS: it seems to me that this resembles the typing discussions here. 
Using non-sensical variable names to explain why type annotations are 
sorely needed.


More information about the Python-ideas mailing list