On 5/26/21 7:40 AM, Steven D'Aprano wrote:
> On Wed, May 26, 2021 at 11:26:17AM -0000, Shreyan Avigyan wrote:
>> Reply to Richard Damon:
>>
>> The values can be changed. It can be mutated (if mutable). This idea
>> suggests we can't reassign anything to the name. Suppose,
>>
>> constant x = ["List"]
>> x.append("something") # OK
>>
>> x = [] # Error
So we only have to check at runtime if name has been marked constant to
handle cases like:
if flag:
constant foo = ["List"]
else:
foo = ["Other"]
or
import mymodule
constant mymodule.foo = ["List"]
or are you going to restrict how constants are created?
>
> At last, a straight answer to the question of what this does. Thank you.
> Your answer here crossed with my previous post.
>
> In the future, can you please try to use standard Python terminology
> instead of ambiguous language?
>
> "The values can be changed" is ambiguous. That can mean mutating an
> object:
>
> x.append(None) # mutation changes the value of x
>
> and it can mean rebinding:
>
> x = None # rebinding changes the value of x
>
>
> So now tell us, what sort of error do you get? Is it a compile-time
> error or a run-time error?
>
>> Think of it as a const *ptr. Don't think of it as const *ptr const.
> What's a const *ptr and a const *ptr const?
He is assuming that people are familiar with C.
--
Richard Damon
_______________________________________________
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/ZACDDCGGNJ32KD3FTAEEFXR5727CZ2AK/
Code of Conduct: http://python.org/psf/codeofconduct/