0

I'm not sure what this is called so I'm unsure what to search for. I have a function which returns a string I need to use the string returned on my instance object.

action = getattr(instance, action_method)(request)
instance.action

But this always evaluate to instance.action where I need it to be the value of action.

I have also tried this:

instance.getattr(instance, action_method)(request)

MarkK
  • 968
  • 2
  • 14
  • 30
  • ok so looking at this then ``getattr(instance, getattr(instance, action_method)(request))`` should work – MarkK Oct 14 '15 at 13:51
  • 4
    You're already using the get-method-by-string-name to get `action`... Why not apply this again?! – deceze Oct 14 '15 at 13:51
  • I presume you want to set an attribute of instance and its name must be the value of `action`. Is that right? If that is the case, as @deceze pointed out... – Pynchia Oct 14 '15 at 13:54

0 Answers0