-1

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"

  • You can find the answer here: http://stackoverflow.com/questions/17255737/importing-variables-from-another-file-python – kbunarjo Dec 28 '16 at 18:15
  • 2
    Welcome to StackOverflow. Please read and follow the posting guidelines in the help documentation. [Minimal, complete, verifiable example](http://stackoverflow.com/help/mcve) applies here. We cannot effectively help you until you post your MCVE code and accurately describe the problem. StackOverflow is not a coding or tutorial service. – Prune Dec 28 '16 at 18:17

1 Answers1

1

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...

Aviad
  • 343
  • 1
  • 7