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

From: Noel Dawe <Noel.Dawe_at_cern.ch>
Date: Wed, 22 Dec 2010 14:36:25 -0600


Ah, thanks! I forgot the ()...

Noel

On Wed, Dec 22, 2010 at 2:29 PM, <wlavrijsen_at_lbl.gov> wrote:

> 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:36:53 CET

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