1

Why doesn't recursion happen when doing this:

there are two .py files in same folder: A.py and B.py

A.py's code:
import B (1 line)

B.py's code:
import A (1 line)

when executing A.py no recursion (error) happens

Why I expect it to happen
whenever importing .py file, its code is executed
so executing A, it imports B
then executing B, imports A
which, in return, again executes A

and that, at first glimpse should be infinite recursion

P.S. working in python 3 so not sure if it happens in 2

Superior
  • 787
  • 3
  • 17

0 Answers0