Skip to main content

A package for event-driven paradigm

Project description

Package Events++



This class is runtime created and its purpose is to be inhereted by the event-driven target class. It has the following structure:

class Events:
    def _event1(...):
        # Implementation...

    def event1(self):
        return self._event1

    def event1(self, value):
        self._event1 = EventManager.make_event(value)

    def _event2(...):
        # Implementation...

    def event2(self):
        return self._event1

    def event1(self, value):
        self._event2 = EventManager.make_event(value)



This class builds the Events class, which must be inherited by the event-driven target class. Its implementation is omitted in this tutorial for it is not relevant for the package usage.

event_driven function

This function gets events names-docstring tuples as attributes, creates an EventManager instance and returns an Events class ready to be inherited.


events_class = event_driven(
                    ('event1', '...'),
                    ('event2', '...'),
                    ('event3', '...'),

Usage example

class TargetClass(event_driven(('event1', '...'), ('event2', '...'))):
    __slots__ = 'baa', 'foo'

    def __init__(self):
        # Implementation...

    def foo_maker(self, value):
        self.baa = self.event2(baa) = self.event1(value, self.baa)

When an event is declared, it is created as None, so that nothing will happen during the execution of self.event2, nor self.event1(value, self.baa). Furthermore, even though None is not callable, when an event is None, it is simply not called, no exception is called.

target_instance = TargetClass()

def new_event1(self, *args):
    # Implementation...

def new_event2(self, baa):
    # Implementation...

Those lines would change event1 and event2 behaviour for target_instance. Although it is not a rule, it is undoubtedly a good habit to use docstring to events for the TargetClass implementation probably expects event1 and event2 to have specific arguments, or none.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

EventsPP-0.0.3.tar.gz (3.5 kB view hashes)

Uploaded source

Built Distribution

EventsPP-0.0.3-py3-none-any.whl (4.3 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page