Skip to content Skip to sidebar Skip to footer

Using Variables From Other Python File

I am making a little game thing in Python, I'm still fairly new to this. I am trying to access a variable in another file by using import, but it keeps saying AttributeError: modu

Solution 1:

The only way I can see you would get this error is if the coolant module also imports coretemp. (BTW, I am assuming here the space in core temp was a copy/paste error)

If coolant imports coretemp it will be accessing a copy of the module as it existed when coretemp imported coolant. That would mean ct is not yet defined.

Note that the import in main will never complete as coretemp.py contains an infinite loop at the top level: main will simply wait for ever for the module it is importing to finish executing.

Post a Comment for "Using Variables From Other Python File"