
Steven D'Aprano writes:
On Thu, Sep 02, 2021 at 04:04:40PM +0900, Stephen J. Turnbull wrote:
You may not need to teach them about singletons, though.
It's hard to teach why `is` works with None,
For definitions of "works" that comes down to "agrees with Nick that 'is' is just a weird way to spell '==' most of the time". But that's not how I think of 'is'.
but not with 1.234 or [], without talking about the object model and singletons.
Object model, of course, but singletons? AFAICS, "singleton" is a red herring here. Object model is important for '[]': there are times where it's important that 'a == b == [] and a is b', and other times where it's important that 'a == b == [] and a is not b'. But from the point of view of beginner education, at least, there's no reason why None and Ellipsis couldn't share a SpecialObjects type (although you couldn't put False and True in there).
To say nothing of why it works with 0 and 1 but not 123456.
Case in point for singletons being a red herring. True == 1 but True is not 1 (in Python 3.10). Neither object is a singleton.