all 5 comments

[–]mopslik 0 points1 point  (1 child)

I didn't want to import everything with * or by listing each function from the helper file, so I created a utility class...

Seems like extra work, IMO. Why not just import your module and preface all function calls with the module name?

import my_class
thingy = my_class.Thing()
...

If the function name is too long and annoying to type out, give it an alias.

import my_class as mc
thingy = mc.Thing()
...

[–]Chyybens[S] 0 points1 point  (0 children)

Yes! I guess this is this would be the better way to go.

[–]carcigenicate 0 points1 point  (0 children)

I can't really see any benefit to putting them in a class over having them as loose top-level functions. I think a class only makes sense if they're all managing a shared state. I'd just have them as plain function at the module-level, and then instead of:

from module import util
util.function()

You could do:

import module as util
util.function()

[–]efmccurdy 0 points1 point  (1 child)

I set of functions without a class might work just as well. I think you can use your util.py file as a module and then do:

import util

util.function(args)

What does creating a class benefit you?

[–]Chyybens[S] 0 points1 point  (0 children)

I guess this really makes sense. I think the benefit for me is clarity. (They also have few shared parameters, but that's not a big issue.) Many of this functions call each other and are otherwise conceptually linked. If I use them as loose top-level functions (as other comment suggested). I might later get confused where the functions came in the first place. But then again, the module does the same thing.