Python中的事件系统

您使用哪个Python事件系统?我已经知道pydispatcher,但我想知道还能找到什么或常用的东西?


我对大型框架中的事件管理器不感兴趣,我宁愿使用可以轻松扩展的小型准系统解决方案。


守着一只汪
浏览 730回答 3
3回答

慕桂英4014372

我一直这样:class Event(list):    """Event subscription.    A list of callable objects. Calling an instance of this will cause a    call to each item in the list in ascending order by index.    Example Usage:    >>> def f(x):    ...     print 'f(%s)' % x    >>> def g(x):    ...     print 'g(%s)' % x    >>> e = Event()    >>> e()    >>> e.append(f)    >>> e(123)    f(123)    >>> e.remove(f)    >>> e()    >>> e += (f, g)    >>> e(10)    f(10)    g(10)    >>> del e[0]    >>> e(2)    g(2)    """    def __call__(self, *args, **kwargs):        for f in self:            f(*args, **kwargs)    def __repr__(self):        return "Event(%s)" % list.__repr__(self)但是,就像我看到的所有其他内容一样,没有为此自动生成的pydoc,也没有签名,这确实很糟糕。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python