MEL with Python with MEL

I’m trying to pass a variable from MEL into a Python function… something along these lines:

$var = 1;
python("import myFile")
python("myFile.myFunc(" + $var + ")");

…but that doesn’t seem to work. Any idea on how to make this work or whether maybe this is not at all possible…?

Assuming your code is pseudo code it should work just fine. Because this works for me:

int $var1 = 42;

python("def printMe(number): print number");
python("printMe(" + $var1 + ")");

That’s odd. I had to do it like this to make it work:

$var = 1;
python("import myFile");
python("myFile.myFunc(\"" + $var + "\")");

Oh well, it works. Moving on… :wink:
Thanks for having a look though!

You were missing a semicolon on your second line.
also to use double quotes inside of double quotes, you need to escape it like you did.

(For anyone stumbling across this later)