Home | News | Documentation | Download

How to call Form in python

This snippet:

for ind in range(0, N):
    key = ROOT.TString("key_") + ROOT.Form("%u", ind)

gives an error:

TypeError: char* ::Form(const char* fmt) =>
    takes at most 1 arguments (2 given)

How to fix?


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hi,
it looks like PyROOT is not binding to the variadic overload of Form correctly, but there is an easy workaround:

//python 3
key = ROOT.TString(f"{ind}")
//python 2
key = ROOT.TString("{}".format(ind))

Cheers,
Enrico

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.