-
Notifications
You must be signed in to change notification settings - Fork 2k
Use __call__ instead of __init__ for classes that define one #286
Copy link
Copy link
Closed
Description
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
- Duplicates Make execution model more robust/flexible #21: Make execution model more robust/flexible
- Related to Use decorator to define tasks #76: Use decorator to define tasks
Closed as Duplicate on 2011-02-05 at 10:52am EST
Reactions are currently unavailable