Added some info about is and ==
This commit is contained in:
parent
aa4c1e23a5
commit
0376b823cf
11
ex_01_03.py
11
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.
|
||||
|
|
Loading…
Reference in New Issue
Block a user