[Python-ideas] __intancehook__ special method
Yahya Abou 'Imran
yahya-abou-imran at protonmail.com
Tue Dec 26 07:02:49 EST 2017
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:
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas