[C++-sig] question on object section of bpl tutorial
Mark Russell
mrussell8081 at pacbell.net
Thu Dec 12 05:43:37 CET 2002
Dave,
I am building a short example for this case--hopefully it will be useful in
the tutorial. I have run into a problem however, I am using msvc 6.5 and
cannot get the following code from the tutorial to compile:
#include <boost/python.hpp>
using namespace boost::python;
void f(str name)
{
object n2 = name.attr("upper")(); // NAME = name.upper()
str NAME = name.upper(); // better
object msg = "%s is bigger than %s" % make_tuple(NAME,name);
}
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
-----Original Message-----
From: c++-sig-admin at python.org [mailto:c++-sig-admin at python.org]On
Behalf Of David Abrahams
Sent: Wednesday, December 11, 2002 5:17 PM
To: c++-sig at python.org
Subject: Re: [C++-sig] question on object section of bpl tutorial
Mark Russell <mrussell8081 at pacbell.net> writes:
> Hi Dave,
>
> A quick question from the basic interface page of the object portion of
the
> bpl tutorial. On this page you show the following code snippet. What
types
> are x & y? --Mark
>
> def f(x, y):
> if (y == 'foo'):
> x[3:7] = 'bar'
> else:
> x.items += y(3, x)
> return x
What types would you like them to be? This is Python, remember? <wink>
Seriously, though: I realize that it's you're unlikely to find types
in common usage for which that code makes much sense. Clarifying
patches welcome.
--
David Abrahams
dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution
_______________________________________________
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