Closed floer32 closed 5 years ago
I think a few such things would continue PyDoit's (awesome) approach of getting things to be concise and clear, while staying very Pythonic. In this case I have a Host
class subclassing tools.Interactive
, and it's very clear to have {'actions': Host.actions(['1', '2', ...])}
. The __eq__
was just something I used while testing (notice it is in the doctest for actions()
classmethod).
For a bit more context ... I also have a subclass of Host
called DockerComposeExec
, and {'actions': DockerComposeExec.actions(['1', '2', ...])}
is very clear as well... (Though in our case we alias for brevity, dcdo = DockerComposeExec.actions
; so we have this concise little thing, {'actions': dcdo(['pytest', 'another-command', 'etc'])
, yet in code there's no magic, all Pythonic in the doit way.
This issue isn't about those Action subclasses, of course, just trying to paint a picture of where some utility methods might be helpful.
doit
was designed so that people can build utility functions like this ...
but I like keep doit
core without those, unless this utility are popular and non-trivial to implement.
ps. doit doesnt support python2 anymore :grimacing:
I found these useful. What do you think about if I cleaned them up and made a PR? Would be Py2 compatible of course, though examples are from Py3 (f-strings etc would be changed).
@classmethod actions
__eq__
Seems like a nice-to-have to be able to compare actions, for debugging or learning purposes. I have this locally (unsure if adequate)