I have a class which should call subprocess.call to run a script as part of it's job.
I've defined the class in a module and at the top of the module I have imported the call function from subprocess.
I am not sure whether I should just use call() inside one of the functions of the class or whether I should make it a data member and then call it via the self.call function object.
I would prefer the latter but I'm not sure how to do this. Ideally I would like not to have subprocess at the top and have something like:
class Base:
def __init__():
self.call = subprocess.call
but the above doesn't work. How would you go about doing this? I'm very new to Python 3.
callfunction at all?Base().call('echo')works for me. Did you mean to forget to specify theselfparameter in the__init__(self)method signature?