Python dictionary in root code

Dear all,

This is more a question regarding python in root than root in python. Is there a way inside a root class to create a python dictionary — with standard information (integers, chains), nothing fancy — and save it as a pickle file?

I’ve read several posts regarding pickle format but I think they were more concern about saving root objects inside a python script than the other way round.

Thanks a lot in advance,

best regards

Esteban

Esteban,

yes: you can generate a CINT (or Reflex) dictionary from Python.h, which then gives you access to the Python C API, usable from root.exe. I did this once with Reflex, just to show that one can.

What I do not understand is that all you ask for is pure python, so why not write a python script to do it all, then call that from root.exe using the TPython interface (http://root.cern.ch/root/html530/TPython.html, where you either want several Exec()s or ExecScript() )?

Cheers,
Wim

P.S. I’ll be traveling in a few hours, won’t be back online for a few days probably.

Thanks Wim,

maybe I did not explain myself properly. Just imagine that I am running over some data runs using a TSelector derived class. I am counting the number of events after a set of cuts. Then the job ends and I want to store that information. I was wondering if one of the possible formats to store that information was a pickle file as a python dictionary. But I think that with the information that you provided me I could do it.

Thanks again!!

Esteban