# This file contains code from `_.py` file with some explanations
# To run this code do `import explanation` somewhere

# sys module is used to:
# - store global variables in it
# - modify sys.modules
import sys

try:
    # normal fib-stuff:
    # a, b = b, a + b
    sys.a, sys.b = sys.b, sys.a + sys.b
except:  # if something goes wrong...
    # it means that sys has no attrs a and b
    # then create them:
    sys.a = sys.b = 1

del sys.modules['explanation']  # delete this module from global module registry
print(sys.a)  # print some fibonacci number
try:
    import explanation  # import this module, it will be executed again, because we deleted it from sys.modules
except:  # if recursion error happens...
    # add some value into sys.modules. It will be returned in `import explanation` statement
    sys.modules['explanation'] = sys.b
