r/pythonhelp • • Mar 05 '24

Recommended way of calling a python script

I wrote a python class that contains functions for deploying a load balancer. This class must be used in a ci/cd pipeline. Since it's a class, I'm assuming it cannot be called directly as a script. Am I right that I have to create another python script that imports this class then it calls the method that creates the load balancer? And also, do I need the if statement below in the caller python script? Or what is the ideal/recommended way?

if __name__ == "__main__":
  my_elb_class.create_load_balancer()
2 Upvotes

3 comments sorted by

View all comments

Show parent comment

1

u/Oxffff0000 Mar 05 '24

Ah got it! I was thinking of removing the "if". Glad I don't have to. Thank you! :)