|
Boost : |
From: Anton Gluck (gluc_at_[hidden])
Date: 2000-11-22 00:59:59
Dave,
<snip>
> length in python, though I don't think you need that in your case. In any
> case, to support the sequence interface, model your vector interface after
> the dangerous_array example, i.e. expose __getitem__, __setitem__ (if you
> want it to be writable) and expecially remember to throw the
> PyExc_IndexError when the index is out-of-range. This will allow you to
> write "for x in S".
Thanks for your discussion of my problem. I talked this over with one of
the programmers who works on the dll I am wrapping, because I had the
problem that in some cases the iterator was the only accessible handle for
Python. We came up with this scheme, which I was able to implement:
Create a new class that uses the iterator from the dll to create its own
vector. Add length(), getItem() etc. to this class. Expose the class -
voila!
It's not as elegant as your solution (I can't do the "for x in S" Python
construct, rather I need to do "for i in range(0, PyVarList.Length()" to
use my VarList example), but it does work.
Thanks for your help, it brought enough clarity to the problem with
iterators to prompt our solution.
Toni
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk