Re: Using iterators to write in the structure being iterated through?

2006-07-28 Thread Pierre Barbier de Reuille
Pierre Thibault wrote: > On Wed, 26 Jul 2006 18:54:39 +0200, Peter Otten wrote: > >> Pierre Thibault wrote: >> [...] > > Now, I want to do simple math operations on the data in C. Doing a loop > from 0 to 49 would loop twice through the actual data. In this > context, an iterator is perfect since

Re: Using iterators to write in the structure being iterated through?

2006-07-27 Thread Pierre Thibault
On Wed, 26 Jul 2006 20:59:12 +0200, Peter Otten wrote: > Pierre Thibault wrote: > >> Hum, this example seems like a special case not really appropriate for my >> needs. Let me make my problem a little more precise. The objects I'll want >> to iterate through will always contain some floats. Very

Re: Using iterators to write in the structure being iterated through?

2006-07-27 Thread Pierre Thibault
On Wed, 26 Jul 2006 16:11:48 -0700, Paddy wrote: > > Paddy wrote: >> Pierre Thibault wrote: >> > Hello! >> > >> > I am currently trying to port a C++ code to python, and I think I am stuck >> > because of the very different behavior of STL iterators vs python >> > iterators. What I need to do is

Re: Using iterators to write in the structure being iterated through?

2006-07-26 Thread Paddy
Paddy wrote: > Pierre Thibault wrote: > > Hello! > > > > I am currently trying to port a C++ code to python, and I think I am stuck > > because of the very different behavior of STL iterators vs python > > iterators. What I need to do is a simple arithmetic operations on objects > > I don't know.

Re: Using iterators to write in the structure being iterated through?

2006-07-26 Thread Paddy
Pierre Thibault wrote: > Hello! > > I am currently trying to port a C++ code to python, and I think I am stuck > because of the very different behavior of STL iterators vs python > iterators. What I need to do is a simple arithmetic operations on objects > I don't know. In C++, the method doing th

Re: Using iterators to write in the structure being iterated through?

2006-07-26 Thread bearophileHUGS
Pierre Thibault, some people here surely know enough Python (and C++) to solve your problem, but often the problem is understanding the problem. I have understood your problem just partially, so the following are just ideas. First of all I suggest you to use a normal Python list to keep the data,

Re: Using iterators to write in the structure being iterated through?

2006-07-26 Thread Peter Otten
Pierre Thibault wrote: > Hum, this example seems like a special case not really appropriate for my > needs. Let me make my problem a little more precise. The objects I'll want > to iterate through will always contain some floats. Very often, I guess > they will be numpy.ndarray instances, but they

Re: Using iterators to write in the structure being iterated through?

2006-07-26 Thread Pierre Thibault
On Wed, 26 Jul 2006 18:54:39 +0200, Peter Otten wrote: > Pierre Thibault wrote: > >> Hello! >> >> I am currently trying to port a C++ code to python, and I think I am stuck >> because of the very different behavior of STL iterators vs python >> iterators. What I need to do is a simple arithmetic

Re: Using iterators to write in the structure being iterated through?

2006-07-26 Thread Peter Otten
Pierre Thibault wrote: > Hello! > > I am currently trying to port a C++ code to python, and I think I am stuck > because of the very different behavior of STL iterators vs python > iterators. What I need to do is a simple arithmetic operations on objects > I don't know. In C++, the method doing t

Re: Using iterators to write in the structure being iterated through?

2006-07-26 Thread Chris Lambacher
I think you are going to need to provide some python minimal code as an example of what is not working for you. -Chris On Wed, Jul 26, 2006 at 11:39:36AM -0400, Pierre Thibault wrote: > Hello! > > I am currently trying to port a C++ code to python, and I think I am stuck > because of the very dif

Using iterators to write in the structure being iterated through?

2006-07-26 Thread Pierre Thibault
Hello! I am currently trying to port a C++ code to python, and I think I am stuck because of the very different behavior of STL iterators vs python iterators. What I need to do is a simple arithmetic operations on objects I don't know. In C++, the method doing that was a template, and all that was