Attributes acting as arrays (in C extensions)?

Dave Cole djc at itga.com.au
Thu Jan 20 22:19:34 EST 2000


>>>>> "Joakim" == Joakim Ziegler <joakim at login1.styx.net> writes:

Joakim> I'm implementing a Python module in C. I've already done
Joakim> object attributes which invoke C functions to get and set the
Joakim> values, but is it possible to have object attributes that act
Joakim> as arrays? So that you can do

Joakim> object.attribute[n]

Joakim> in Python, and call a C function with object, the name of the
Joakim> attribute, and n as arguments? I've not been able to find docs
Joakim> on how to do this.

I suppose you could implement that particular attribute as another C
object which implements the sequence interface.

- Dave



More information about the Python-list mailing list