Should use a class in Python to only modify the workflow of an application?

Viewed 53

I am new working with classes in Python and I think I am misunderstanding something.

I am developing an application that allow the user to run a small test to ensure everything is OK. This is the code

## main.py ##

# Import libraries
from classes.test.test_control import TestingControl

user_input = sys.argv[1]

if user_input == 'run_test':
    # Run test control
    TestingControl()

## test_control.py

class TestingControl:
    def test_control_vcf()
    ...
# The class and the function don't need any argument

Do I really need a class to do this, or is it a good practice to use directly a function instead?

I have read the following link but still, it is not clear if in this example I should use it

When should I be using classes in Python?

(I could use directly the function, that's work but (apart from this is going to be evaluated) I want to learn.

1 Answers

This comes to a personal choice. I would recommend to watch Stop Writing Classes by Jack Diederich, Jack is a python core developer. I have attached a link to the youtube video. And at the end it's your call, whether you want a class or a function is fine.

https://youtu.be/o9pEzgHorH0

Related