[Python-ideas] Python docs page: In what ways is None special
Chris Barker
chris.barker at noaa.gov
Tue Aug 14 18:57:54 EDT 2018
On Tue, Aug 14, 2018 at 10:25 AM, David Mertz <mertz at gnosis.cx> wrote:
> Great work! There are a few typos, I'll try to get to a PR on those.
>
> I wonder if it's worth noting that None is a singleton, while 42 is just a
> value. I.e. there might be several distinct objects that happen to be the
> int 42, but not so with None.
>
very much worth nothing -- and I think re-wording that example. The fact
that you can't assign to None is orthogonal to the fact that it's immutable.
in fact, [42] is a llteral for a list with one element, the integer with
the value of 42 in it. It is very much a mutable. and yet:
In [7]: [42] = 34
File "<ipython-input-7-b919f2b4d30d>", line 1
[42] = 34
SyntaxError: can't assign to literal
whereas:
[5].append(3)
works -- at least it does not result in an error -- even though it's
useless.
And the reason this matters is that name binding (and rebinding) is very
much a different operation than mutating -- we should not conflate those.
-CHB
--
Christopher Barker, Ph.D.
Oceanographer
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...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180814/7e2e338e/attachment.html>
More information about the Python-ideas
mailing list