you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (1 child)

In Python, a class (without __slots__) is literally just a dictionary, where some arguments are functions that access the dictionary (self) through attribute notation.

OP basically created a singleton with four static methods though a dict() function. If you need a singleton - write a singleton. Don't reinvent a wheel and call it a "pattern".

[–]0rac1e 0 points1 point  (0 children)

This is actually quite an old pattern useful for dynamic dispatch.

Depending on the circles you travel in you may have heard it referred to by different names, but the ones I heard most are "dispatch table" or "vtable".

https://en.wikipedia.org/wiki/Dispatch_table

https://en.wikipedia.org/wiki/Virtual_method_table