The whole point of the if __name__...
is that it's for things that are only needed when the module is executed as a script, ie exactly if it's not being imported from another class. So no, you don't need to do this.
Your explanation of why you can't put things into a function make no sense; that is exactly what you should do.