[C++-sig] question on object section of bpl tutorial

Mark Russell mrussell8081 at pacbell.net
Thu Dec 12 19:56:29 CET 2002


This works just fine.  Thanks Mark

-----Original Message-----
From: c++-sig-admin at python.org [mailto:c++-sig-admin at python.org]On
Behalf Of Nicodemus
Sent: Thursday, December 12, 2002 3:47 AM
To: c++-sig at python.org
Subject: Re: [C++-sig] question on object section of bpl tutorial




Mark Russell wrote:

>The compiler cannot resolve the str ambiguity--I did some research on this
>and I guess my compiler is one of the broken ones that can't do this
>automatically :{  I have made several tries at explicitly specifying the
>name but no joy--how do I do this?  --Mark
>

Hi Mark,

I have the same problem, unfortunately (Intel C++ 6.0). I assume that 
you're doing a 'using namespace boost::python' at the top of the module.

So, there's two cases where you can use str:

1) When you are dealing with a PyString:

str x( "Hello"  );

To solve this, simply preppend 'boost::python::':

boost::python::str x( "Hello" );


2) When you're exporting the __str__ method:

...
.def( str(self) )
...

To solve the ambiguity, preppend 'boost::python::self_ns::' (or just 
'self_ns::'):

.def( boost::python::self_ns::str(self) )
or
.def( self_ns::str(self) )


Hope this helps.
Nicodemus.



_______________________________________________
C++-sig mailing list
C++-sig at python.org
http://mail.python.org/mailman/listinfo/c++-sig




More information about the Cplusplus-sig mailing list