Passing the arguments to Loadmacro

Hello,

Is it possible to pass the arguments when calling a root macro from the pyhton script with Loadmacro?

Thank you

Hi,

I’m not 100% sure what you’re asking: LoadMacro() does not take any argument parameters. You can give CLI to python using a ‘-’ as separator if you do not provide a file, and pick those up in your macro through gApplication->Argc() and gApplication->Argc().

Presumably you are asking about sharing variables from python into the CINT macro? Something like:

gotra.C:[code]#include

void gotra() {
cout << a << " " << b << " " << c << endl;
}[/code]

gotra.py:[code]import ROOT

ROOT.a = "aap"
ROOT.b = 42
ROOT.c = 3.1415
ROOT.gROOT.LoadMacro( ‘gotra.C’ )

ROOT.gotra()[/code]
which will print “aap 42 3.1415”.

Cheers,
Wim

Thank you Wim,

I wasn’t aware of this syntax. It is clear now.

Sincerely,
Yuri