How do I get a variable from one file into another file

103 views Asked by At

I want to get my class variables from file x and use them in file y. How can I go about doing this?

I have seen that you would use from fileName import * but when i use this i get a error "import * only allowed at one module level"

1

There are 1 answers

5
Aviad On

A.py

VAR1 = 'foo'
VAR2 = 'bar

B.py

from A import VAR1, VAR2

Assuming files A.py and B.py are located in the same folder...