[Python-ideas] Should Python have user-defined constants?
chris.barker at noaa.gov
Tue Nov 21 12:34:33 EST 2017
On Tue, Nov 21, 2017 at 3:31 AM, Steven D'Aprano <steve at pearwood.info>
> interesting (but is it useful?) concept is constant identifiers which
> cannot be re-bound or re-assigned once they are set the first time.
This would actually be a substantial shift in what Python is about --
currently the concept of type is all about values, not names -- there are
various rules about scope, and they can be adjusted with global and
nonlocal, but it's only about scope -- a name is still a name, and can be
bound to any type of object, etc.
static languages, on the other hand often (always) assign type to the name
itself -- so adding constants and the like makes sense. But changing the
property of a name (this name can not be rebound) is a big shift in what
names are about in Python -- and I don't think a good one.
And what's the use-case, really? beyond the use case for all sorts of
in case it's not obvious: -1
Christopher Barker, Ph.D.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas