David Abrahams wrote:
Dan Nuffer <[EMAIL PROTECTED]> writes:6. How can I get python indexing and slicing to work on OW_String? I couldn't see any information about this in the docs.The same way you do it in Python: supply a "__getitem__" and a "__getslice__" method.
Thanks, this works great!
7. Do I need to expose the copy constructor and assignment operator via Boost.Python?You don't need assignment at all, and the copy constructor is exposed automatically unless you have specified that your class is noncopyable. You may want to build a copy() method, as Ralf suggests we ought to do automatically in http://aspn.activestate.com/ASPN/Mail/Message/c++-sig/1386367 (I'm now beginning to think we should just generate copy() automatically).
I'm not quite sure what I'm doing here. I couldn't find an example that does this. This doesn't compile:
.def("copy", init<const OW_String&>())
This doesn't work:
OW_String OW_String_copy(const OW_String& s)
{
return s;
}
...
.def("copy", &OW_String_copy)
>>> t = copy.deepcopy(s)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/local/lib/python2.2/copy.py", line 182, in deepcopy
y = _reconstruct(x, reductor(), 1, memo)
File "/usr/local/lib/python2.2/copy.py", line 305, in _reconstruct
args = deepcopy(args, memo)
File "/usr/local/lib/python2.2/copy.py", line 186, in deepcopy
y = copierfunction(x, memo)
File "/usr/local/lib/python2.2/copy.py", line 226, in _deepcopy_tuple
y.append(deepcopy(a, memo))
File "/usr/local/lib/python2.2/copy.py", line 182, in deepcopy
y = _reconstruct(x, reductor(), 1, memo)
File "/usr/local/lib/python2.2/copy_reg.py", line 57, in _reduce
raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle instance objects
How am I supposed to do this?
Thanks,
Dan Nuffer
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost