Well, I fact, I was playing with metaclasses and descriptors, and I was 
thinking about a way to use the famous variable annotation to instatiate 
decrptors like this:

class Point(metaclass=MyMeta):
    x: int
    y: int

class Circle(metaclass=MyMeta):
    center: Point
    radius: PositiveInteger

Here the radius must be [strictly] positive, but since I'm using the 
annotations to get the type to test in the __set__ method of the descriptor, I 
didn't found a more elegant way than that...

And it was before I knew the existance of dataclasses!!! I was pretty shocked 
by the way. Maybe I can make this compatible with it anyway.
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to