Getting a python dict into a root macro in 6.08.06

Indeed it seems that there are problem with the LCG88 environment you are using.

First off, I also see the

'map<TString,vector<string> >' object has no attribute 'emplace'

Which seems like a bug to me. Not present anymore in recent ROOT versions.

Then, when using the insert method, among the various errors that appear (and you also showed in a previous comment), the real culprit is

  pair<_Rb_tree_iterator<pair<const TString,vector<string> > >,bool> map<TString,vector<string> >::insert(const pair<const TString,vector<string> >& __x) =>
    could not convert argument 1

This tells you that the conversion of the argument mymap.insert((ROOT.TString("another"), ["d", "e", "f"])) doesn’t work. The reason why it doesn’t work is that the translation from a simple tuple (i.e. (ROOT.TString("another"), ["d", "e", "f"])) to an actual std::pair<TString, std::vector<std::string> is not supported (in that particular version of ROOT).

ROOT 6.08 is an ancient version of ROOT at this point and the Python<->C++ translation layer (cppyy) wasn’t as mature as today. Thus what you are experiencing doesn’t surprise me. I suggest you make sure to use the latest ROOT version possible.

A possible workaround, although extremely cumbersome, would be to take care of explicitly instantiating all the objects needed to satisfy the signature of map::insert, e.g.

v = ROOT.std.vector("string")()
v.push_back("el1")
v.push_back("el2")
p = ROOT.std.pair("const TString", "std::vector<std::string>")("theTString", v)
mymap.insert(p)

Cheers,
Vincenzo