>>>>> I have a predefined set of members, some of which are optional. >>>> Having optional fields is also a good reason. >>> What is the use of T_OBJECT_EX vs T_OBJECT in PyMemberDef then? >> Right - this works for optional objects. However, it can't possibly >> work for any of the other fields. > > I have two members, one T_OBJECT and one T_OBJECT_EX. Both are NULL and both > still appear in the dir() output. For one, accessing it returns 'None', for > the other it raises an exception. I would have expected an element that is > not accessible, not even 'None', to also not be visible in dir().
I understood your expectation already. I maintain my theory that it shows up because there is a descriptor on the class. >> I suppose that's because there will still be a descriptor for the >> field in the class. > > So is that intentional or is it dir() that could be improved there? It's probably both. > Should I file a bugreport? Only if you can provide a patch also. My guess is that when you have the patch completed, you might realize that it is not an improvement, despite achieving what you wanted to achieve. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list