For someone who doesn’t generally monkey-patch things, what motivated you
to make this library? Could you post a use-case? Looking at your example,
how does your library differ from this?

def whoAmI(self):
    print("My name is %s" % [self.name](http://self.name/)())

OpenMaya.MFnTransform.whoAmI = whoAmI

On another note, you’ve got a well executed readthedocs page and your
docstrings are very well formatted. It’s quite a joy to read.
​


On 23 June 2014 18:04, Marcus Ottosson <[email protected]> wrote:

> Hey Christopher,
>
> I'm seeing the post fine on this end (via Gmail) and will look through
> your code in a bit, looks cool!
>
> Best,
> Marcus
>
>
> On 23 June 2014 17:03, Christopher Crouzet <[email protected]>
> wrote:
>
>> I think there has been a glitch with my Gmail—can anyone see a subject
>> other than "untitled" or see this post at all?
>>
>>
>>
>> On 23 June 2014 11:47, Christopher Crouzet <[email protected]
>> > wrote:
>>
>>> Hi there,
>>>
>>>
>>> I've initially posted this message onto the Softimage mailing-list but
>>> since it's referring to Maya I hope you don't mind me posting it here as
>>> well.
>>>
>>> Basically I've just published an article about how to monkey patch
>>> external libraries in Python while using the Maya Python API as a guinea
>>> pig. While I was there, I also came up with a couple of open source
>>> libraries on that matter.
>>>
>>> You can find the article and all the information over there: From
>>> Monkey Patching the Maya Python API to Gorilla and Bananas
>>> <http://christophercrouzet.com/blog/post/2014/06/23/From-Monkey-Patching-the-Maya-Python-API-to-Gorilla-and-Bananas>—I
>>> hope you don't mind the bashing on the Maya API :)
>>>
>>>
>>> And here's a short(er) version:
>>>
>>> Monkey patching allows you to modify an existing 3rd-party library by
>>> inserting some code of yours. Once the process is done, you can call the
>>> extensions you've inserted as if they have always been part of that
>>> 3rd-party library.
>>>
>>> The article uses Maya as a playground but the technique can definitely
>>> be applied to about anything, which is what the library Gorilla
>>> <https://github.com/christophercrouzet/gorilla> is all about. You write
>>> your functions, classes, methods, properties, whatever, you tell them the
>>> target to patch with the help of a Python decorator, and that's about it.
>>> You can find more details in the documentation
>>> <http://gorilla.readthedocs.org/>.
>>>
>>> As a proof of concept for this project, I've developed a couple of
>>> extensions for the Maya Python API. Say hi to Banana for Maya
>>> <https://github.com/christophercrouzet/banana.maya>. This basically
>>> shows that extending the API can be as simple as:
>>>
>>>     @gorilla.patch(OpenMaya.MFnTransform)
>>>     def whoAmI(self):
>>>         print("My name is %s" % self.name())
>>>
>>>
>>> Which allows you to fire the method through a call to `
>>> OpenMaya.MFnTransform.whoAmI()`.
>>>
>>> As for the extensions already in there, there's a shiny documentation
>>> <http://bananamaya.readthedocs.org/> for this one too.
>>>
>>> Once again the `banana.maya` package is only a proof of concept, which
>>> is why it's a bit empty. I've started to implement some methods that could
>>> hopefully be useful to everyone (mainly retrieving/iterating through the
>>> nodes in the scene) but I'm currently not using Maya anymore and don't have
>>> any direct interest in developing those extensions much further. The
>>> exception being if there's a need for it and if discussions can be
>>> organized to implement the right features.
>>>
>>> Note that I'm not saying that monkey patching the Maya Python API v1.0
>>> is the way to go and I acknowledge that there's better alternatives out
>>> there for most cases.
>>>
>>>
>>> That's about it. The code is yours, do what you want with it.
>>>
>>> Cheers,
>>> Christopher.
>>>
>>> --
>>> Christopher Crouzet
>>> *http://christophercrouzet.com* <http://christophercrouzet.com>
>>>
>>>
>>
>>
>> --
>> Christopher Crouzet
>> *http://christophercrouzet.com* <http://christophercrouzet.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/CANuKW52Luo-S-OabmBdxeXdfiCZuJTViV2MTju3pQyO8CXdLaQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/python_inside_maya/CANuKW52Luo-S-OabmBdxeXdfiCZuJTViV2MTju3pQyO8CXdLaQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> *Marcus Ottosson*
> [email protected]
>



-- 
*Marcus Ottosson*
[email protected]

-- 
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/CAFRtmOBkznpZeHg0pe09fzftXOuWg-JcwshZuUTdstGqdFA%3D8Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to