# Using the six.py library in Jython 2.5

**URL:** <https://forum.inductiveautomation.com/t/using-the-six-py-library-in-jython-2-5/9842>\
**Category:** Ignition\
**Created:** [March 25, 2015, 8:33pm UTC](https://forum.inductiveautomation.com/t/using-the-six-py-library-in-jython-2-5/9842 "2015-03-25T20:33:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![HCIdivision17](https://avatars.discourse-cdn.com/v4/letter/h/65b543/32.png) [@HCIdivision17](https://forum.inductiveautomation.com/u/HCIdivision17)\
**Post date:** [March 25, 2015, 8:33pm UTC](https://forum.inductiveautomation.com/t/using-the-six-py-library-in-jython-2-5/9842/1 "2015-03-25T20:33:50Z")

</div>

In case anyone else runs into an operator.methodcaller issue, I’ve attached a quick fix.

Here’s the story:  
When trying to load a third party python library into Ignition, the Jython compiler was dying on a call in six.py (which I also added from the [Cheese Shop](https://pypi.python.org/pypi/six/1.9.0)). The problem was that operator didn’t have methodcaller in it. Some searching showed that Jython 2.5 had a bug causing this, and [a patch was submitted](http://grokbase.com/t/python/jython-checkins/126pegfba4/jython-add-operator-methodcaller-thanks-jezreel-ng) with a fix. Unfortunately, patching Jython is a bit out of my league.

But [monkey patching](http://stackoverflow.com/a/6647776) six.py isn’t. Since I didn’t know what the code should be, I went to the source on implementing python in python: [PyPy](http://pypy.org/). A quick search of the PyPy source code yeilded the following block of code

```auto
class methodcaller(object):
    def __init__ (self, method_name, *args, **kwargs):
        self._method_name = method_name
        self._args = args
        self._kwargs = kwargs

    def __call__ (self, obj):
        return getattr(obj, self._method_name)(*self._args, **self._kwargs)
```

So that code, immediately followed by

```auto
operator.methodcaller = methodcaller
```

and plopped directly after the imports in six.py patched it.

This has the nice feature that a lot of super handy Python libraries use six.py, but there’s nothing too complicated going on here to make it work. Cheers!  
[six.py](https://us1.discourse-cdn.com/inductiveautomation/original/2X/2/243492410179bfa9ebc598328da9410825a6df1f.py) (29.5 KB)

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [March 26, 2015, 6:23pm UTC](https://forum.inductiveautomation.com/t/using-the-six-py-library-in-jython-2-5/9842/2 "2015-03-26T18:23:02Z")

</div>

Cool, thanks!
