'Register an event notification.
@param eventtype: the desired event type to be notified about.
@param callback: the function to call when the event occurs.
@param args: optional positional arguments for the callback.
@param kwds: optional keyword arguments for the callback.
@return: 0 on success, ENOMEM on error.
@note: The callback function must have at least one argument,
an Event instance.  Any other, optional positional and keyword
arguments are in B{addition} to the first one.'

def event_attach(self, eventtype, callback, *args, **kwds):

    if (not isinstance(eventtype, EventType)):
        raise VLCException(('%s    required:    %r' % ('EventType', eventtype)))
    if (not hasattr(callback, '__call__')):
        raise VLCException(('%s    required:    %r' % ('callable', callback)))
    if (not any(getargspec(callback)[:2])):
        raise VLCException(('%s    required:    %r' % ('argument', callback)))
    if (self._callback_handler is None):
        _called_from_ctypes = ctypes.CFUNCTYPE(None, ctypes.POINTER(Event), ctypes.c_void_p)
        @_called_from_ctypes
        def _callback_handler(event, k):
            '(INTERNAL)    handle    callback    call    from    ctypes.\n\n                                                                @note:    We    cannot    simply    make    this    an    EventManager\n                                                                method    since    ctypes    does    not    prepend    self    as    the\n                                                                first    parameter,    hence    this    closure.\n                                                                '
            try:
                (call, args, kwds) = self._callbacks[k]
                call(event.contents, *args, **kwds)
            except KeyError:
                pass
        self._callback_handler = _callback_handler
        self._callbacks = {}
    k = eventtype.value
    r = libvlc_event_attach(self, k, self._callback_handler, k)
    if (not r):
        self._callbacks[k] = (callback, args, kwds)
    return r
