From 0376b823cfaeb1821d6f9f122ae936497281dc29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kn=C3=BCttel?= Date: Wed, 24 Oct 2018 17:46:55 +0200 Subject: [PATCH] Added some info about is and == --- ex_01_03.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ex_01_03.py b/ex_01_03.py index ee95a1e..d0e1b46 100644 --- a/ex_01_03.py +++ b/ex_01_03.py @@ -12,3 +12,14 @@ def bailey_borwein_plouffe_pi(n): if( __name__ == "__main__"): assert bailey_borwein_plouffe_pi(1000) == math.pi + + # Please note that the ``is`` operator checks wether the + # two references are the same object, basically by comparing + # their pointers. + # + # The ``==`` operator accesses the ``__eq__`` method of the + # object that *compares* the other object to itself. + # + # Because ``a/b`` **cannot** return the same object as ``math.pi``, + # the latter was created when the module ``math`` was initialized, + # this will **always** evaluate to False.