18 Nov
2011
18 Nov
'11
3:17 a.m.
Lee l_armeanu@yahoo.co.nz writes:
This is exactly my problem. What I am trying to do (and the example seems to show) is:
- define an new type.
- define getsetters functions.
- say, if one want to delete an attribute, one writes in the setter function:
if (value == NULL) { PyErr_SetString(PyExc_TypeError, "Cannot delete the last attribute"); return -1; }
Does unchanged noddy2.c work correctly for you? (It seems to contain the exact check you are quoting.) Maybe you are compiling noddy2 with a compiler incompatible to the one used for building Python?
so, one expects that can do:
import noddy2 mynoddy = noddy2.Noddy(number=15) mynoddy.first = "a" try: del mynoddy.last except TypeError, e: print "Error: ", e
This should be possible, yes.