Maik Beckmann wrote:
Murray Cumming schrieb am Montag 23 Februar 2009 um 12:39:
I'm trying to support this notation in python:
something = record["somefieldname"]
[snip]
I'm now trying to do this with boost::python, like so, because googling
has suggested that this should work:
boost::python::class_<Glom::PyGlomRecord>("Record")
.def("__getitem__", &Glom::PyGlomRecord::getitem)
.def("__len__", &Glom::PyGlomRecord::len)
But when I try to use that in Python, I get this error:
"Boost.Python.class' object is unsubscriptable"
You're trying to subscript a class, not an instance of a class. I bet
you've got something like this:
r = Record
feh = r['thing']
which is wrong... you want:
r = Record()
feh = r['thing']
-t
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig