How to make menu dynamicaly with command variable

Hello! I need to use a variable to initialized a class that will be called when click on menu items.
As I understand it, this cannot be done through a string command, so I use a script_object, something like:
@unreal.uclass()
class ScriptObject(unreal.ToolMenuEntryScript):
def init(self, command):
super().init()
self.command = command

     @unreal.ufunction(override=True)
     def execute(self, context):
         self.command()

and call script_object = ScriptObject(command)
script_object.init_entry( …)

But the @unreal.ufunction(override=True) (?) decorator does not allow the variable to be used internally and assigns it to None
Is there a way to solve this problem?