On Wed, May 26, 2021 at 1:38 PM Shreyan Avigyan <pythonshreyan09@gmail.com> wrote:
Reply to Stestagg:

That's annotation to make sure no one uses a name.

This is a proposal to implement constant name binding in Python.

Here are some excerpts from pep 591, specifically, how are they different from what you are proposing?

[typing.Final purpose] "Declaring that a variable or attribute should not be reassigned"



The two main rules for defining a final name are:

  • There can be at most one final declaration per module or class for a given attribute. There can't be separate class-level and instance-level constants with the same name.
  • There must be exactly one assignment to a final name.


[typing.Final is useful in...]"Allowing a name to be used in situations where ordinarily a literal is expected (for example as a field name for NamedTuple, a tuple of types passed to isinstance, or an argument to a function with arguments of Literal type [3])."

There are many applications of constants.

However many there may be, the cases discussed here all fall under this definition

Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/DDDMEDIXHMYLTZP7TJHWC5ECDJRF4CWU/
Code of Conduct: http://python.org/psf/codeofconduct/