Since my privatization trick works in both IDLE and the python3 REPL:
>>> class A(object):
... __slots__ = ['attr']
...
>>> dscget = A.__dict__['attr'].__get__
>>> dscset = A.__dict__['attr'].__set__
>>> del A.attr
>>>
but not quite in my program (same exact setup and mechanics)
Python 3.4.3 |Anaconda 2.3.0 (32-bit)| (default, Mar 6 2015, 12:08:17) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
Traceback (most recent call last):
File "\home\tcll\Projects\python\UGE\test_FORMAT.py", line 5, in <module>
import API
File "\home\tcll\Projects\python\UGE\API\__init__.py", line 43, in <module>
from . import CONST, OBJECT
File "\home\tcll\Projects\python\UGE\API\OBJECT\__init__.py", line 191, in <module>
from ._collection import *
File "\home\tcll\Projects\python\UGE\API\OBJECT\_collection.py", line 209, in <module>
private()
File "\home\tcll\Projects\python\UGE\API\OBJECT\_collection.py", line 187, in private
getbase, setbase = getset( UGECollection, '__base__' ); del UGECollection.__base__
AttributeError: readonly attribute
>>>
I should note this is actually the 3rd class that loads, the first 2 classes actually work as expected and load without issue, though they don't delete the attributes, only overwrite them with read-only properties.
I want to know how member_descriptor is initialized and registered to the class so I can look into creating them without the need for a reference in the class dict.
the member_descriptor name can be obtained easily, but instance creation seems very difficult:
>>> class A(object):
... __slots__ = ['attr']
...
>>> member_descriptor = A.attr.__class__
>>> member_descriptor()
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
member_descriptor()
TypeError: cannot create 'member_descriptor' instances
>>> member_descriptor.__new__(member_descriptor)
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
member_descriptor.__new__(member_descriptor)
TypeError: object.__new__(member_descriptor) is not safe, use member_descriptor.__new__()
>>>
I'm pretty sure it's impossible to do it through python, but how can I do it through something like ctypes or cffi??