[Baypiggies] Descriptors with metaclasses don't quite seem to work
ams.fwd at gmail.com
Thu Jan 3 01:38:52 EST 2019
I have the following code where I am adding a metaclass to a descriptor.
This is a reduction case so the metaclass really does nothing.
Running this with python3 does not appear to trigger the descriptors
__get__ or __set__. Without the metaclass things work as expected. I am not
exactly sure why having the metaclass would not work as all the attributes
for the descriptor appear to be preserved.
Any help would be greatly appreciated.
# -*- coding: utf-8 -*-
def __init__(cls, name, bases, attrs):
super().__init__(name, bases, attrs)
def __call__(cls, *args, **kwargs):
inst = super().__call__()
self._val = None
def __get__(self, obj, obj_type):
def __set__(self, obj, value):
print('-- setting value')
self._val = value
x = X()
m = M()
m.x = 1
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Baypiggies