Reverse Lookup
Consider the following class hierarchy:
class Pokemon(Registry, case_sensitive=False):
pass
class Pikachu(Pokemon):
pass
class SurfingPikachu(Pokemon):
pass
Subclasses can be accessed via the standard AutoRegistry indexing, i.e:
assert Pokemon["pikachu"] == Pikachu
To perform the reverse-lookup, i.e. obtain the string "pikachu"
from the
class Pikachu
, access the __registry__.name
attribute:
assert Pikachu.__registry__.name == "pikachu"