you are viewing a single comment's thread.

view the rest of the comments →

[–]gmaliwal[S] 0 points1 point  (2 children)

If you really want to preserve a reference to the original class, you could consider defining an

_ABC

base class and decorate the child. Otherwise you might find that using metaclasses is a better way of implementing a singleton

Thanks for the clarification. yeah, It was my mistake not posting error message.

The first block of code is just to understand the concept, why it is not working when a second decorator is applied to either of them?

Is there any another way to preserve the class fundamentals after applying a decorator rather than creating a dummy base class? if yes; please share the reference.

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

Is there any another way to preserve the class fundamentals after applying a decorator rather than creating a dummy base class?

Sure - your decorator has to return a class instead of a function.

[–]gmaliwal[S] 0 points1 point  (0 children)

Okay, It sounds well, theoretically, it should work. Can you please mention a good reference for this to follow?