
26 May
2021
26 May
'21
6:01 p.m.
Reply to Paul Moore:
if some_condition: constant a = 1 else: a = 2 a = 3
Yes this is allowed. This is runtime.
for i in range(10): constant a = []
Not sure. Though it's preferable to be runtime. Preferable is "not allowed".
And lists are also literals. Any Python Object that is not assigned to a variable is a literal. Python claims that itself. A preview -
[10] = [2] SyntaxError: Can't assign to literal here.
Constants should have a similar error -
constant x = 10 x = [2] SomeErrorType: Can't assign to constant here.