Suppose I have such a method in the fablib.py file:

 def init(file='production_server.yaml', f_before=before_init, f_after=after_init): f_before() # This function will be called from other module server = ServerSSH(file) # my class server.create_dir() server.init() f_after() # This function will be called from other module too 

Next, I create the file fabfile.py . How do I make the functions f_before and f_after so that they are visible and called in the function of the fablib module?

Running the script using the fab command.

    1 answer 1

    Import them in the fablib.py module and set them as default values ​​in the init function.

    In the fablib.py file:

     from fabfile import f_before, f_after def init(file='production_server.yaml', f_before=f_before, f_after=f_after): .... 

    Or like this:

     from fabfile import f_before as before_init from fabfile import f_after as after_init