Python does not force you to use OOP, for example, for example. Java or C #, so you donβt need to put things in classes unless there is a real benefit to you from this.
- IMHO. . - , . , .
:
main.py:
if __name__ == "__main__":
import sys
args = sys.argv[1:]
if len(args) != 2:
print("This script requires exactly two command-line arguments!")
exit(1)
import my_module
exit_code = my_module.run(args) or 0
exit(exit_code)
else:
raise ImportError("Run this file directly, don't import it!")
my_module.py:
def run(args):
print("Hello world!")
print("You said <", args[0], "> and <", args[1], ">."
! ( ) , , , , .
. , , , . , , .
( ) , , if __name__ == "__main__" .