Re: ROOT 5.28 unbound method in ROOT.vector (python)

From: <wlavrijsen_at_lbl.gov>
Date: Wed, 22 Dec 2010 12:29:56 -0800


Hi,

>>>> import ROOT
>>>> a = ROOT.vector("int")
>>>> a

> <class 'ROOT.vector<int,allocator<int> >'>

>>>> a.push_back(1)
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> TypeError: void vector<int,allocator<int> >::push_back(const int& x) =>
>    unbound method vector<int,allocator<int> >::push_back must be called
> with a vector<int,allocator<int> > instance as first argument

yes, as the message says, the method is unbound and needs to be called on an instance, not on the class. Try this:

>>> import ROOT
>>> a = ROOT.vector(int)()
>>> print a

<ROOT.vector<int> object at 0x8b531c0>
>>> a.push_back(1)
>>>

Note how it says vector<int> object rather than class vector<int> for a.

Best regards,

            Wim

-- 
WLavrijsen_at_lbl.gov    --    +1 (510) 486 6411    --    www.lavrijsen.net
Received on Wed Dec 22 2010 - 21:30:19 CET

This archive was generated by hypermail 2.2.0 : Wed Dec 22 2010 - 23:50:01 CET