[C++-sig] Re: [Boost-Users] Python and hello.World class example

David Brownell david_brownell at hotmail.com
Wed Jun 18 16:42:20 CEST 2003


Joel, thank you for your reply - I am now a member of the Boost Python
mailing list as well.  I am actually quite embarrassed as to what my problem
was, and it is painful to admit it here in public :)  I wasn't creating a
new instance of the object before I tried to access the object's methods.
Sometimes python's syntax is so easy, I expect it to read my mind!  Adding
that "fix" makes the quite logical errors go away.


"Joel de Guzman" <djowel at gmx.co.uk> wrote in message
news:04b501c3358e$61a4bc00$0100a8c0 at godzilla...
> David Brownell wrote:
> > I am trying to run the hello.World class example in the tutorial and
> > am running into problems.  I can compile the dll fine, and then copy
> > the dll (and the boost_python.dll) into my python directory, and then
> > start my Python interpreter.  The library will import, but when I
> > call either the greet or set methods, I get the following errors from
> > within the Python interpreter:
> >
> > [greet]:
> > Traceback (most recent call last):
> >   File "<interactive input>", line 1, in ?
> > TypeError: unbound method Boost.Python.function object must be called
> > with World instance as first argument (got str instance instead)
> >
> > [set]:
> > Traceback (most recent call last):
> >   File "<interactive input>", line 1, in ?
> > TypeError: unbound method Boost.Python.function object must be called
> > with World instance as first argument (got nothing instead)
> >
> > I am failrly new to Python and even newer to Boost.Python, so there
> > may be something very basic that I am missing.  I am using boost
> > 1.30, bjam to compile, MSVC 7.1, Python 2.2, and Windows XP.  Note
> > that I can compile and successfully execute the inital Hello World
> > example (hello.cpp in the tutorial subdir).
>
> Hi David,
>
> FYI, Boost.Python has its own mailing list. It would be nice to see you
there ;-)
> http://mail.python.org/mailman/listinfo/c++-sig
>
> Anyway, I'm a bit lost. Could you please copy and paste the exact Python
> session? Have you tried the example session in the tutorial?:
>
>     >>> import hello
>     >>> planet = hello.World()
>     >>> planet.set('howdy')
>     >>> planet.greet()
>     'howdy'
>
> Regards,
> -- 
> Joel de Guzman
> joel at boost-consulting.com
> http://www.boost-consulting.com
> http://spirit.sf.net







More information about the Cplusplus-sig mailing list