Skip to content
Advertisement

Pass multiple variables from one module to another

I have several modules in the folder “Programm/modules” which are called by another script in “Programm”.

One for example looks like this:

“calculate.py”

JavaScript

this I would like to load into another module “print.py”

JavaScript

But I get the error "ModuleNotFoundError: No module named 'calculate'"

What’s wrong?

EDIT

Thx guys, I can now load the module with:

JavaScript

And I changed the return to:

JavaScript

But now I get:

JavaScript

How can I import “x” and “y” into “print.py”?

Advertisement

Answer

if your programm folder looks like this:

JavaScript

from modules.calculate import calculate

EDIT:

use the value you return to assign it to a variable. like x, y = calculate(). Now you can use (these) x and y in your print.py like this:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement