Added some info about is and ==

This commit is contained in:
Daniel Knüttel 2018-10-24 17:46:55 +02:00
parent aa4c1e23a5
commit 0376b823cf

View File

@ -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.