Typing Number, PyCharm
Weatherby,Gerard
gweatherby at uchc.edu
Mon Feb 6 10:07:31 EST 2023
Yeah, I’m confused.
“The Decimal Type<https://peps.python.org/pep-3141/#the-decimal-type>
After consultation with its authors it has been decided that the Decimal type should not at this time be made part of the numeric tower.” https://peps.python.org/pep-3141/#the-decimal-type
And the Decimal definition I’m finding says:
class Decimal(object):
yet
print(issubclass(Decimal,Number))
returns True.
From: Paul Bryan <pbryan at anode.ca>
Date: Monday, February 6, 2023 at 9:25 AM
To: Weatherby,Gerard <gweatherby at uchc.edu>, dn <PythonList at DancesWithMice.info>, 'Python' <python-list at python.org>
Subject: Re: Typing Number, PyCharm
*** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***
On Mon, 2023-02-06 at 12:11 +0000, Weatherby,Gerard wrote:
On the one hand, it is a well-known type, so it should be recognizable to users of an API. On the other hand, Number is entirely abstract, so it doesn’t provide useful type checking for the implementation; I had to add # noinspection PyTypeChecker to 2 * value to keep PyCharm from complaining. Additionally, it does not include the Decimal type.
Hmm...
Python 3.10.9 (main, Dec 19 2022, 17:35:49) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from numbers import Number
>>> from decimal import Decimal as D
>>> isinstance(D("1.0"), Number)
True
More information about the Python-list
mailing list