C API []-style access to instance objects
williams.jasonscott at gmail.com
williams.jasonscott at gmail.com
Wed Apr 26 18:51:06 EDT 2006
Hi,
I am having trouble figuring out how to set up an object to be
scriptable through the C API. An example of what I am attempting to
do:
>>> obj = foo.Foo()
>>> obj["key"]
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: unsubscriptable object
>>>
I've tried defining __getitem__ as a method, but that hasn't worked.
Is there a tp_field that I am failing to understand, something like
tp_iter and tp_iternext?
thanks~
More information about the Python-list
mailing list