Python class inheriting from ROOT class

Is it possible to do something along the lines of

[code]class MyClass( ROOT.TNamed )

ROOT.RootThingThatTakesTObject( MyClass() )[/code]

I tried something along these lines but the constructor wanted some arguments. Any advice? Is this sort of thing even possible or am I forced to generate them outside python as suggested in this article?


  • Peter


the talk at last ROOT Users workshop: explains the issues (see slide 20 and 21). In short: for a method to be called virtually, it needs to have an entry in the C++ vtable. The usual way for a python method to achieve this, is to setup a forwarding method. Originally, I envisioned (and made prototype of) this based on ACLiC. However, it was agreed to get more direct support from CINT and I’m still waiting on that.

So yes, for now, the easiest is to use a compiled C++ class. If you are interested in writing a forwarding method by hand, let me know (basically: keep a weak reference to a Python object, and implement a C++ override method in an intermediate class that performs the forward).


Any progress on this? :slight_smile:

  • Pete

Hi Peter,

no; I don’t expect to get time to breathe (let alone work on fun stuff) until ATLAS release 14.0.0 is out of the door (Feb/Mar '08 or sometime around that), prior to startup. :frowning: