vendredi 2 décembre 2022

Best way to create a global helper functions in python, Singleton, Static methods?

I want to create an object or some functionality that will execute 3 commands for now.

Below is a code template

class Shell:
   def __init__(self):
       print("")
       
"""
    Execute Command - Example execute subprocess("LS") 
    Execute Command Get Output - Example execute subprocess("LS") and capture result
    Execute Command and leave hanging. - Execute subprocess("LS") leave process on
    
"""

Above is a dummy example, my main question is I want to call these methods multiple times from my program, like each time I need to run a command in CMD it should call those, now would I need a single instance for each process, I would say no, so do I make these static or I make a singleton or do I leave OOP and make simple helper functions?

Aucun commentaire:

Enregistrer un commentaire