commit | 9ed8b44033e64f2990bf123b5057e92b8142edae | [log] [tgz] |
---|---|---|
author | Orell Garten <10799869+orgarten@users.noreply.github.com> | Tue Apr 21 15:02:55 2020 +0200 |
committer | Wenzel Jakob <wenzel.jakob@epfl.ch> | Sun Apr 26 09:21:42 2020 +0200 |
tree | ccbba0999bc285205acdf96a0712772b4ecd5396 | |
parent | 5088364b967d3cf57e99d7d352b8a52230788b0c [diff] |
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.
diff --git a/docs/advanced/cast/custom.rst b/docs/advanced/cast/custom.rst index e4f99ac..f803594 100644 --- a/docs/advanced/cast/custom.rst +++ b/docs/advanced/cast/custom.rst
@@ -23,7 +23,7 @@ .. code-block:: python class A: - def __int__(self): + def __new__(cls): return 123 from example import print