Skip to content

Event subscription callback on instance method #7

@6p9hb3ukynd3n8er

Description

@6p9hb3ukynd3n8er

Hi,

I noticed this check when specifying the callback function of an event subscription :

if type(callback) is not type(lambda x: x):

In both python 2 and 3, type(lambda x: x) is <type 'function'> but in python2, a class or instance method is <type 'instancemethod'> and in python3 an instance method is <class 'method'>.

I think using the builtin callable() function would be more appropriate and would allow the use of an instance method as a callback. This modification solved the issue for me.

if not callable(callback):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions