-3

I have a legacy piece of code that I'm upgrading to python3 but I've been stuck on the alternative of the apply python2 function that was dropped in python2.3 and replaced with function however function isn't working in python 3.8 Is there an alternative to this function?

I have return apply(fn, args, kwargs) I have tried return function(fn, args, kwargs)

but in both cases I'm getting a NameError

E_K
  • 2,159
  • 23
  • 39
  • 4
    `return fn(*args, **kwargs)` – Marat Sep 27 '21 at 14:00
  • 3
    You're misunderstanding what it's been replaced by. Not the "`function` function", but simply `fn(*args, **kwargs)`. – deceze Sep 27 '21 at 14:00
  • I still get Here is what I get `>>> fn(*args, **kwargs)` `Traceback (most recent call last):` `File "", line 1, in ` `NameError: name 'fn' is not defined` – E_K Sep 27 '21 at 14:03
  • 2
    `fn` is **the function you're trying to call!** You're giving us an example of "`apply(fn, ...)`", so we're telling you it's `fn(...)`. Whatever that function is called in your actual code we don't know. – deceze Sep 27 '21 at 14:04

1 Answers1

1

Basically fn(*args, **kwargs) should solve your problem

Jonathan1609
  • 1,809
  • 1
  • 5
  • 22