0

I have 3 Files

A.py

import pandas as pd
import C as c

dfresult = pd.read_csv("result.csv",sep=",")
figure = c.figure

B.py

import A


dfresult = A.dfresult

C.Py

import B as b

dfresult = b.dfresult

...creating figures

if i use B to read in the data and dont import A in B it is working, if i import the A file (my startfile) i get allways module A has no attribute dfresult and so on

Please explain why?

Eric Stralsund
  • 541
  • 1
  • 5
  • 17
  • 1
    Line 2 in A imports C, which imports B, which tries to import A again. A is already loaded so we go to the next line a B which is accessing `A.dfresult`. But `dfresult` in A has not yet been evaluated because so far we're only on the second line of A. – blueteeth Feb 29 '20 at 12:16
  • so it only depends on the sequence of the commands? – Eric Stralsund Feb 29 '20 at 13:03
  • Yes? Python is interpreted line by line, so when you import something you have to imagine that the interpreter is now going through every line in the imported file. – blueteeth Feb 29 '20 at 14:26
  • 1
    Does this answer your question? [Circular (or cyclic) imports in Python](https://stackoverflow.com/questions/744373/circular-or-cyclic-imports-in-python) – Olli Niskanen Feb 29 '20 at 15:24

0 Answers0