79226626

Date: 2024-11-26 12:04:43
Score: 1.5
Natty:
Report link

I had this issue and found this question. But figured out a workaround for my situation.

result = cls(name="throwaway instance").instance_method(var_to_process, instance_situational_flag=False)

I have an instance method that situationally calls on data that is instance-specific. When I'm in the @classmethod I want to use the non-situationally specific version. I looked into making this instance method into a class method, but that was just wonky. I don't use the @classmethod in question very often, so the slight performance hit isn't a big deal for me.

Alternatively, it seems like the person asking the question could have been trying to use a @classmethod where a Singleton Design Pattern might have been more appropriate: https://refactoring.guru/design-patterns/singleton

Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @classmethod
  • Low reputation (0.5):
Posted by: turbonate