1

I have a data science codebase that contains several classes. Several of the methods in the classes rely upon various helper functions. These functions will just precede the class definitions in my module.

My question is, is it accepted practice to have these helper functions outside of a class? The benefit of this is that when I call these functions in the class, I can just refer to them by their name without any sort of prefix.

1
5

Python is a multi-paradigm language. You don't have to force your code into an object-oriented style. In fact, you shouldn't.

So if it feels more natural to keep the helper functions as free functions outside of the class, that's probably a perfectly acceptable design. It's also the kind of design I would generally prefer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.