Re:Javascript-Style Objects in Python
by voyou on Monday March 16, 2015 @01:47PM
(#9212994)
I don't think you need to use metaclasses, you can just define the relevant magic methods, something like:
ETA: That gets you JavaScript-style equivalence between attribute and index lookup, but it doesn't get you JavaScript-like binding of "this". I think you could probably do that with descriptors (and maybe it would require writing a metaclass).
[ Parent
| on HN ]
Re:Javascript-Style Objects in Python
by icebraining on Monday March 16, 2015 @01:49PM
(#9213013)