Code Monkey home page Code Monkey logo

events's Introduction

Events

Bringing the elegance of C# EventHanlder to Python

https://secure.travis-ci.org/nicolaiarocci/events.png?branch=master

The C# language provides a handy way to declare, subscribe to and fire events. Technically, an event is a "slot" where callback functions (event handlers) can be attached to - a process referred to as subscribing to an event. Here is a handy package that encapsulates the core to event subscription and event firing and feels like a “natural” part of the language.

>>> def something_changed(reason):
...     print "something changed because %s" % reason
...

>>> from events import Events
>>> events = Events()
>>> events.on_change += something_changed

Multiple callback functions can subscribe to the same event. When the event is fired, all attached event handlers are invoked in sequence. To fire the event, perform a call on the slot:

>>> events.on_change('it had to happen')
'something changed because it had to happen'

Documentation

Complete documentation is available at http://events.readthedocs.org

Installing

Events is on PyPI so all you need to do is:

pip install events

Testing

Just run:

python setup.py test

The package has been tested under Python 2.6, Python 2.7 and Python 3.3.

License

Events is BSD licensed. See the LICENSE for details.

Contributing

Please see the Contribution Guidelines.

Attribution

Based on the excellent recipe by Zoran Isailovski, Copyright (c) 2005.

events's People

Contributors

nicolaiarocci avatar oyvindio avatar

Watchers

 avatar James Cloos avatar texuf avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.