Skip to content

Commit 4568a11

Browse files
committed
Fix Registry Pattern with __metaclass__ word.
1 parent cc312ad commit 4568a11

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

registry.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def get_registry(cls):
2020
return dict(cls.REGISTRY)
2121

2222

23-
class BaseRegisteredClass(metaclass=RegistryHolder):
23+
class BaseRegisteredClass:
24+
__metaclass__ = RegistryHolder
2425
"""
2526
Any class that will inherits from BaseRegisteredClass will be included
2627
inside the dict RegistryHolder.REGISTRY, the key being the name of the
@@ -30,18 +31,20 @@ class and the associated value, the class itself.
3031

3132
if __name__ == "__main__":
3233
print("Before subclassing: ")
33-
for k in RegistryHolder.REGISTRY:
34+
for k in RegistryHolder.REGISTRY.keys():
3435
print(k)
3536

3637
class ClassRegistree(BaseRegisteredClass):
3738

3839
def __init__(self, *args, **kwargs):
3940
pass
41+
42+
4043
print("After subclassing: ")
4144
for k in RegistryHolder.REGISTRY:
4245
print(k)
4346

44-
### OUTPUT ###
47+
### OUTPUT ###
4548
# Before subclassing:
4649
# BaseRegisteredClass
4750
# After subclassing:

0 commit comments

Comments
 (0)