How to avoid PyROOT interpreting command line parameters?

Hi,

I write python scripts with PyROOT, and root (I guess the TApplication equivalent) always interprets my command line parameters. For example, if I call my script with -h, it exits on the first instantiation of a root object and displays the help of the root binary. How can I turn this off?

I can try to circumvent it by evaluating my own help before creating any root object instance. But this is no clean way since other parameters can lead to interference if they change root settings although I just wanted to change a parameter of my own part of the program - that every parameter is evaluated twice worries me.

Another fix is to copy sys.argv to a temporary variable, create a root object instance and restore sys.argv afterwards, but also doesn’t look like a proper way of dealing with this.

Here is a simple example. I put the path of the script into the $PATH variable and call it directly via its name, e.g. “test.py -h”

#!/usr/bin/python

import ROOT

can = ROOT.TCanvas("can","")

results into

Usage: /usr/bin/python [-l] [-b] [-n] [-q] [dir] [[file:]data.root] [file1.C ... fileN.C]
Options:
  -b : run in batch mode without graphics
  -x : exit on exception
  -n : do not execute logon and logoff macros as specified in .rootrc
  -q : exit after processing command line macro files
  -l : do not show splash screen
 dir : if dir is a valid directory cd to it before executing

  -?      : print usage
  -h      : print usage
  --help  : print usage
  -config : print ./configure options
  -memstat : run with memory usage monitoring

Cheers,
Christian

Christian,

import ROOT ROOT.PyConfig.IgnoreCommandLineOptions = True
Cheers,
Wim

Thank you Wim, that was exactly what I was looking for.

Cheers,
Christian