I'm doing a python project where I got a tons of very different functions. I want to somehow organize them together for the future usage, and, of course, for the easier debugging.
However, is it good habit to arrange lots of functions in a class so that they would be attributes, or just put them all in a file?
A related post could be found here: Differences between `class` and `def` where the author specifically indicated that "class is used to define a class (a template from which you can instantiate objects)", so it seemed like functions, methods to change the objects, might not be used as class.
But the official python documentation stated that "Classes provide a means of bundling data and functionality together." So arranging a bunch of functions in a class seemed to be a suggested habit.
A attempt example was achieved as following
class class1(object):
"""description of class"""
def fun1(x,y):
return x**2+y**2
where
class1.fun1(1,2)
returned the result 5. As shown, the function fun1 was now better organized, and one could easily find where it was and debug it.
However, one could simply import the function fun1 from a file as
def fun1(x,y):
return x**2+y**2
and use it as
fun1(1,2)
which was messier.
Should I arrange all those function in a class as attributes, or just put them all in a file?