Totally valid. Thanks for the suggestion, it's way easier and pythonic :)


---
[image: Nicolas Chaverou - Golaem Crowd Product Manager - Golaem SA]

+33 (0)2 99 27 21 44
http://www.golaem.com

On Mon, May 28, 2018 at 1:00 PM, Justin Israel <[email protected]>
wrote:

> I definitely second the suggestion from Marcus and recommend to avoid
> trying to construct a text based expression to pass to eval. Inverting the
> design and offering a callback registration is much more flexible and
> reliable.
>
>
> On Mon, May 28, 2018, 10:34 PM Marcus Ottosson <[email protected]>
> wrote:
>
>> How about this, for the user:
>>
>> import glm
>> def mycallback():
>>   print("Did it!")
>>
>> glm.registerUserCallback(mycallback)
>>
>> That way, your registerUserCallback can take and store the callback,
>> regardless of whether it’s from the Script Editor or another module.
>> ​
>>
>> On 28 May 2018 at 11:20, Nicolas Chaverou <[email protected]>
>> wrote:
>>
>>> Hi guys,
>>>
>>> I'm trying to implement a user callback mechanism;
>>> I'm having a function in a predefined module called glm.utils :
>>>
>>> def createNodeUserCallback(functionName, nodeName):
>>>     callbackFunction = functionName + 'UserCallback'
>>>     call = callbackFunction + '(\'' + nodeName + '\')'
>>>     try:
>>>         eval(call)
>>>     except:
>>>         mutils.warning('Error while calling Python user callback')
>>>
>>> This function is called here and there with different parameters and
>>> expects our users to declare and source some functions
>>> Those functions are sometimes declared in their own modules (not known
>>> from our side) or in the Maya Script Editor
>>>
>>> Problem is those functions are not available from our glm.utils module.
>>> Someone has an idea about how I could solve this ?
>>>
>>> Thanks
>>>
>>> ---
>>> [image: Nicolas Chaverou - Golaem Crowd Product Manager - Golaem SA]
>>>
>>> +33 (0)2 99 27 21 44
>>> http://www.golaem.com
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Python Programming for Autodesk Maya" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/python_inside_maya/CAFS5DCarx4ENBitQT8G-_
>>> dcqpSDuVtSdmW5Q0rpAy76naVN%2BnA%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/CAFS5DCarx4ENBitQT8G-_dcqpSDuVtSdmW5Q0rpAy76naVN%2BnA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit https://groups.google.com/d/
>> msgid/python_inside_maya/CAFRtmOCjyGX-Nz0L7pJ4J0v8jfNVEUA%
>> 2Bf5OXzcnSF5stCme_cw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCjyGX-Nz0L7pJ4J0v8jfNVEUA%2Bf5OXzcnSF5stCme_cw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/python_inside_maya/CAPGFgA2%3Dvpnk4d14S5TCYGw%
> 2BVkjPXuLySoMR_ssspd9_4sqzPA%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2%3Dvpnk4d14S5TCYGw%2BVkjPXuLySoMR_ssspd9_4sqzPA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFS5DCYKOza41Hxw4OCDwn%2BtE%3DjNh_mQfrK2vYyRB_W0%3DRNy-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to