IF Statements that will call different functions with argparse

江枫思渺然 提交于 2020-03-25 21:05:11

问题


I really dont think what I'm asking for is difficult but I can't find anything that helps without it talking about integers or different kind of arguments. I just want to call different functions using argparse. I want to call either the SHC updater, HCM, or Cloud. Right now it does all 3.

I need if statements.

if __name__ == "__main__":

    def _msg(updated):
        return "was updated" if updated else "already up-to-date"

    HCM_Updater = HCM()
    updated = HCM_Updater.update()
    print("HCM {}.\n".format(_msg(updated)))

    SHC_Updater = SHC()
    updated = SHC_Updater.update()
    print("SHC {}.\n".format(_msg(updated)))

    Cloud_Updater = Cloud()
    updated = Cloud_Updater.update()
    print("Cloud {}.\n".format(_msg(updated)))

来源:https://stackoverflow.com/questions/60820952/if-statements-that-will-call-different-functions-with-argparse

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!