On Wed, 26 May 2021 at 12:59, Shreyan Avigyan <[email protected]> wrote:
> 4. constant pi = 3.14
> # later
> pi = 3.1415 # Error
Steven's already asked what error, and is it compile time or runtime. I'll add
foo.py:
constant x = 12
bar.py
import foo
foo.x = 19
You can only detect this at runtime.
baz.py
import foo
name = 'x'
setattr(foo, name, 22)
You can only detect this at runtime.
Also,
if some_condition:
constant a = 1
else:
a = 2
a = 3
Is this allowed? Is a constant?
What about
for i in range(10):
constant a = []
Is this allowed, or is it 10 rebindings of a?
for i in range(10):
constant a = [i]
What about this? What is a "literal" anyway? You've used lists in
examples (when discussing mutability) but list displays aren't
actually literals.
Lots of questions. I'm sure it's possible to answer them. But as the
proposer, *you* need to give the answers (or at least give a complete
and precise enough specification that people can deduce the answers).
At the moment, everyone is just guessing.
Paul
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/GJ6XAJMGXLWUYORFCFSADT2EBRORXFOI/
Code of Conduct: http://python.org/psf/codeofconduct/