-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
Closed
Labels
Description
Documentation
The decimal
module exports three constants BasicContext
, ExtendedContext
and DefaultContext
, which are instances of Context
:
$ python3
Python 3.13.1 (main, Dec 20 2024, 10:15:12) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import decimal
>>> type(decimal.BasicContext)
<class 'decimal.Context'>
The documentation of module decimal
is misleading by containing these 3 declarations:
class decimal.BasicContext
...class decimal.ExtendedContext
...class decimal.DefaultContext
...
This made me think that these are subclasses of Context
that need to be instantiated like this:
>>> decimal.setcontext(decimal.ExtendedContext())
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
decimal.setcontext(decimal.ExtendedContext())
~~~~~~~~~~~~~~~~~~~~~~~^^
TypeError: 'decimal.Context' object is not callable
I would expect the declarations to look more like the ones e.g. under Rounding modes.
Linked PRs
- gh-128349: use
.. data::
instead of.. class::
for pre-defined decimalContext
objects #128379 - [3.13] gh-128349: Use
.. data::
instead of.. class::
for pre-defined decimalContext
objects (GH-128379) #128401 - [3.12] gh-128349: Use
.. data::
instead of.. class::
for pre-defined decimalContext
objects (GH-128379) #128402
Metadata
Metadata
Assignees
Labels
Projects
Status
Todo