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

Steven D'Aprano steve at pearwood.info
Tue Nov 21 06:33:49 EST 2017


On Tue, Nov 21, 2017 at 11:40:14AM +0100, Stéfane Fermigier wrote:

> for i in range(0, 100):
>    const foo = f(i)
>    const bar = g(i, foo)
>    do_something_with(bar)

I wouldn't expect that to work. You are binding some value f(0) to the 
constant name "foo" on the first loop, then on the second loop you try 
to rebind a new value to the same name "foo". I would expect that to be 
an error.


-- 
Steve


More information about the Python-ideas mailing list