Descriptor Protocol
I couldn't find any information on this, but is the Descriptor Protocol supported. Or is there some way to archive something like this?
search __get__ at https://docs.python.org/3/reference/datamodel.html
The descriptor protocol is not supported. Please explain what you want to achieve, so I can better help you find a workaround.
Hey, I'm sorry for not having answered yet.
When I opened this issue I was looking for a way on how I could do something like this:
class Document:
def write(self, *args, **kwargs):
print(*args, **kwargs)
document = Document()
class State(object):
def __init__(self, initval):
self.val = initval
def __get__(self, obj, objtype):
return self.val
def __set__(self, obj, val):
self.val = val
obj.update()
class View:
def __init__(self):
document.write(self.render())
def update(self):
document.write(self.render())
class Main(View):
number = State(0)
def click_handler(self):
self.number = 1
def render(self):
return f"The number is {self.number}"
main = Main()
main.click_handler()
It's nothing I really need. I just was trying around whats was possible. And I thought it might be interesting for implementing a simple fronted framework in python. But I guess using a function like setState() would be way easier and much more perfoment.
@JdeH Do callable class instances (instances of classes with a __call__ method) behave properly in Transcrypt as bound instance methods even if their __get__ isn't called?