Triple-Quotes and ProcessLine

I am following the advice from http://phacker.org/2009/03/08/using-pyroot-to-write-a-ttree/ but I was tempted to use python’s triple-quotes to avoid using so many insane backslashes. Unfortunately it seems there is a problem, notice the difference between:

[code]import ROOT
s = “”“
struct mys{
Int_t N;
};”""
ROOT.gROOT.ProcessLine(s)

(Bool_t)1
end with ‘;’, ‘@’:abort >
[/code]
and

[code]import ROOT
s = "struct mys{
Int_t N;
};"
ROOT.gROOT.ProcessLine(s)

0L
[/code]

Is there some trick to using the triple-quotes properly to make readable root-input in the pyroot script?

Hi,

the line-continuation with backslashes is for the benefit of ProcessLine(), not for python. You could do a string replace on it for “\n” to “”, but then you’d have to make sure the last end-of-line doesn’t get changed with it. Otherwise the only thing to it is to put the full definition on one line.

Cheers,
Wim