My coworker (Styler) was recently trying to use the ‘attributeMenu’ command and pass in the 'regPulldownMenuCommand ’ argument. This command requires that argument to be a string, NOT a callable, which is unlike most pymel/maya cmds (in fact, passing in a callable will probably give you a SyntaxError when it tries to cast it to a string and evaluate it…). Even better, it must be the name of a MEL Proc, NOT a Python callable.
We ended up doing an awesome (not) workaround where we use mel.eval to create a MEL proc, which invokes your Python callable (which must unfortunately be accessible from a string, ie it cannot be an instance method or inner function), the return value of which is returned from the synthesized MEL proc.
This actually isn’t TOO bad a hack since it’s localized and doesn’t change design much, but I was wondering if there’s a better way to handle this? Trying to write a generalized, testable function to wrap an arbitrary python callable to be invoked from MEL, while possible in theory, ends up with an absurd signature and limitations (may as well write one-offs like for above).