On Fri, Sep 11, 2020 at 9:46 AM Stephen J. Turnbull

> itself doesn't seem to be enough to produce inf:


Indeed -- overflow and underflow and divide by zero all all caught and
raise. But you can get it with a simple huge literal:

In [22]: 1e1000

Out[22]: inf

But if there is going to be a change, just import inf and nan into the
>
> builtin namespace as identifiers.


Indeed — that’s what the PEP will propose.


> Christopher Barker writes:
>
>  > Another point is that these are not going to be singletons, like True,
>
>  > False and None
>
> Singleton isn't the problem here.  inf = None causes no problems if
>
> that's what you want to do.  It's that those three names are keywords,
>
> and can't be used as identifiers.


But why are they keywords? In Py2, True and False were just identifiers-
they were made keywords in py3.

I’m suggesting that one reason that they were made keywords is that it's
useful for them to be singletons, which is much harder to do (or at least
use consistently) if the names can be reassigned.

But these float special values can't be singletons anyway -- they could
come from anywhere, so you really don't want to have people doing:

something is inf
or
something is nan

test anyway. Which means there really isn't a reason to make them keywords
at all.

 > -- they are just floats that happen to have particular values.
>
> s/floats/identifiers/
>

The values are floats, but inf and nan are syntactically identifiers, not
> floats.
>

indeed -- I meant that the object bound to math.inf and math.nan (and if
this goes through bound to the built in names) are just floats with
particular values. No different than, say, math.pi, or 1.2 for that matter.

As far as I can tell, there is no way to instantiate a different bool,
which we would not want to do with these special values -- even if it were
even possible.

-CHB
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/DQOMOJ3YW4BAVGWGG2LFQW54MWWWHJQL/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to