def _python_to_plug(value, plug):
    'Pass value of `value` to `plug`\n\n    Arguments:\n        value (any): Instance of Python or Maya type\n        plug (Plug): Target plug to which value is applied\n\n    '
    if isinstance(value, (tuple, list)):
        if (plug.type() == 'kMatrixAttribute'):
            assert (len(value) == 16), "Value didn't appear to be a valid matrix"
            return _python_to_plug(Matrix4(value), plug)
        for (index, value) in enumerate(value):
            if isinstance(value, (tuple, list)):
                raise TypeError(('Unsupported nested Python type: %s' % value.__class__))
            _python_to_plug(value, plug[index])
    elif isinstance(value, om1.MObject):
        node = _encode1(plug._node.path())
        shapeFn = om1.MFnDagNode(node)
        plug = shapeFn.findPlug(plug.name())
        plug.setMObject(value)
    elif isinstance(value, om.MEulerRotation):
        for (index, value) in enumerate(value):
            value = om.MAngle(value, om.MAngle.kRadians)
            _python_to_plug(value, plug[index])
    elif isinstance(value, om.MAngle):
        plug._mplug.setMAngle(value)
    elif isinstance(value, om.MDistance):
        plug._mplug.setMDistance(value)
    elif isinstance(value, om.MTime):
        plug._mplug.setMTime(value)
    elif isinstance(value, om.MQuaternion):
        _python_to_plug(value.asEulerRotation(), plug)
    elif isinstance(value, om.MVector):
        for (index, value) in enumerate(value):
            _python_to_plug(value, plug[index])
    elif isinstance(value, om.MPoint):
        for (index, value) in enumerate(value):
            _python_to_plug(value, plug[index])
    elif isinstance(value, om.MMatrix):
        matrixData = om.MFnMatrixData()
        matobj = matrixData.create(value)
        plug._mplug.setMObject(matobj)
    elif plug._mplug.isCompound:
        count = plug._mplug.numChildren()
        return _python_to_plug(([value] * count), plug)
    elif isinstance(value, string_types):
        plug._mplug.setString(value)
    elif isinstance(value, int):
        plug._mplug.setInt(value)
    elif isinstance(value, float):
        plug._mplug.setDouble(value)
    elif isinstance(value, bool):
        plug._mplug.setBool(value)
    else:
        raise TypeError(("Unsupported Python type '%s'" % value.__class__))
Pass value of `value` to `plug`

Arguments:
    value (any): Instance of Python or Maya type
    plug (Plug): Target plug to which value is applied
def _python_to_plug(value, plug):
    'Pass value of `value` to `plug`\n\n    Arguments:\n        value (any): Instance of Python or Maya type\n        plug (Plug): Target plug to which value is applied\n\n    '
    if isinstance(value, (tuple, list)):
        if (plug.type() == 'kMatrixAttribute'):
            assert (len(value) == 16), "Value didn't appear to be a valid matrix"
            return _python_to_plug(Matrix4(value), plug)
        for (index, value) in enumerate(value):
            if isinstance(value, (tuple, list)):
                raise TypeError(('Unsupported nested Python type: %s' % value.__class__))
            _python_to_plug(value, plug[index])
    elif isinstance(value, om1.MObject):
        node = _encode1(plug._node.path())
        shapeFn = om1.MFnDagNode(node)
        plug = shapeFn.findPlug(plug.name())
        plug.setMObject(value)
    elif isinstance(value, om.MEulerRotation):
        for (index, value) in enumerate(value):
            value = om.MAngle(value, om.MAngle.kRadians)
            _python_to_plug(value, plug[index])
    elif isinstance(value, om.MAngle):
        plug._mplug.setMAngle(value)
    elif isinstance(value, om.MDistance):
        plug._mplug.setMDistance(value)
    elif isinstance(value, om.MTime):
        plug._mplug.setMTime(value)
    elif isinstance(value, om.MQuaternion):
        _python_to_plug(value.asEulerRotation(), plug)
    elif isinstance(value, om.MVector):
        for (index, value) in enumerate(value):
            _python_to_plug(value, plug[index])
    elif isinstance(value, om.MPoint):
        for (index, value) in enumerate(value):
            _python_to_plug(value, plug[index])
    elif isinstance(value, om.MMatrix):
        matrixData = om.MFnMatrixData()
        matobj = matrixData.create(value)
        plug._mplug.setMObject(matobj)
    elif plug._mplug.isCompound:
        count = plug._mplug.numChildren()
        return _python_to_plug(([value] * count), plug)
    elif isinstance(value, string_types):
        plug._mplug.setString(value)
    elif isinstance(value, int):
        plug._mplug.setInt(value)
    elif isinstance(value, float):
        plug._mplug.setDouble(value)
    elif isinstance(value, bool):
        plug._mplug.setBool(value)
    else:
        raise TypeError(("Unsupported Python type '%s'" % value.__class__))