ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> c++-sig
c++-sig
Re: [C++-sig] On wrapping vector >
by Zhang Le other posts by this author
Oct 2 2003 3:48AM messages near this date
Re: [C++-sig] typo in pyste breaking -= and *= operators | [C++-sig] problem with Boost.Python enum with duplicate values
>  From: Nicodemus <nicodemus@[...].br>
>  Subject: Re: [C++-sig] On wrapping vector<pair<string, double> >
>  To: Development of Python/C++ integration <c++-sig@[...].org>
>  Message-ID: <3F7963B7.3030904@[...].br>
>  Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>  
>  It is hard to tell by your description of the problem alone, some code 
>  would help. But try this:
>  
>  py::list py_eval(py::list v)
>  {
>      vector< pair<string, double> > input;
>      int i;
>      int len = py::extract<int>(v.attr("__len__")());
>  ...
Thank you. I have tracked the bug:
I forget to use attr("__len__") to get the length of a list. Actually,
I'm trying to do:
     size_t len = py::extract<size_t> (v);

I have an additional question: How to detect a type of a py::object in
boost.python?

I want to change my function to accept either 'str' or 'list' type.
py_eval(py::object obj) {
   if (type(obj) is 'str') {
      ...
   } else if (type(obj) is 'list' or 'tuple') {
   ...
   }
}

How to do the above statements in c++ code?

Thanks.
-- 
                                     Sincerely yours,
                                            Zhang Le

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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved