[Libre-soc-bugs] [Bug 1094] insndb instruction database visitor-walker is needed
bugzilla-daemon at libre-soc.org
bugzilla-daemon at libre-soc.org
Sat Jun 10 17:01:24 BST 2023
https://bugs.libre-soc.org/show_bug.cgi?id=1094
--- Comment #102 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
from https://realpython.com/python-metaclasses/:
class VisitorMeta(type):
def __new__(cls, name, bases, dct):
x = super().__new__(cls, name, bases, dct)
x.registry = collections.defaultdict
return x
class Visitor(metaclass=VisitorMeta): pass
class Visitor2(Visitor): pass
Visitor.registry[5] = 2
Visitor2.registry[9] = 7
print (Visitor.registry) # {5: 2}
print (Visitor2.registry) # {9: 7}
ta-daaaaa :)
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the libre-soc-bugs
mailing list