From 9ed8b44033e64f2990bf123b5057e92b8142edae Mon Sep 17 00:00:00 2001 From: Orell Garten <10799869+orgarten@users.noreply.github.com> Date: Tue, 21 Apr 2020 15:02:55 +0200 Subject: [PATCH] Change __init__(self) to __new__(cls) __init__(self) cannot return values. According to https://stackoverflow.com/questions/2491819/how-to-return-a-value-from-init-in-python __new__(cls) should be used, which works. --- docs/advanced/cast/custom.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/advanced/cast/custom.rst b/docs/advanced/cast/custom.rst index e4f99ac5b..f80359431 100644 --- a/docs/advanced/cast/custom.rst +++ b/docs/advanced/cast/custom.rst @@ -23,7 +23,7 @@ The following Python snippet demonstrates the intended usage from the Python sid .. code-block:: python class A: - def __int__(self): + def __new__(cls): return 123 from example import print