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 >> cpp-sig
cpp-sig
Re: [C++-sig] Iterators for heterogeneous container
by Troy D. Straszheim other posts by this author
Nov 7 2009 11:45AM messages near this date
Re: [C++-sig] Iterators for heterogeneous container | Re: [C++-sig] Iterators for heterogeneous container
Thomas Daniel wrote:
>  
>  BOOST_PYTHON_MODULE(vegetables)
>  {
>     class_<Garden>("Garden")
>         .def("get_potatoes", &Garden::get_potatoes)
>         .def("get_tomatoes", &Garden::get_tomatoes)
>     ;
>     class_<TomatoIter>("TomatoIter")
>         .def("__iter__", &TomatoIter::get_next)
>     ;
>  }
>  
>  That at least compiles - unlike all my previous attempts that generate 
>  three pages of template errors - but python complain:
>  
>  TypeError: iter() returned non-iterator of type 'Tomato'
>  
>  so now I am trying to figure out how to tell boost that get_tomatoes 
>  returns an iterator ...
>  

Please don't top-post, guys

As you know, python iterators have a function next() that returns the 
next object in the iteree, or throw StopIteration when they're at the 
end.  As you also know, python expects member functions __iter__() to 
return an iterator.  Is the thing returned by TomatoIter::get_next an 
iterator, ie does it implement the iterator interface?

-t

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@[...].org
http://mail.python.org/mailman/listinfo/cplusplus-sig
Thread:
Thomas Daniel
Michele De Stefano
Thomas Daniel
Troy D. Straszheim
Thomas Daniel

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