Skip to content

Use __call__ instead of __init__ for classes that define one #286

@bitprophet

Description

@bitprophet

Description

A classname is callable as a task, with the arguments being passed to the init function. Not sure if this is by-design or just a consequence of Python syntax.

But if classes are meant to be callable, it might be more useful if call was passed the parameters, so "class task: def init(self):.... def call(self, args, kwargs)" would create an instance using the no-arg constructor, then pass processed command-line args into call. This would allow tasks to be derived from a base class, pass stuff to init for inheritance, then expose either custom or the base class's call method for actually running the task.


Originally submitted by Adam Vandenberg (adamv) on 2011-02-05 at 12:53am EST

Relations


Closed as Duplicate on 2011-02-05 at 10:52am EST

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions