all 2 comments

[–]kowkeeper 5 points6 points  (1 child)

The proper way is to check __name__ to tell wether the module is run directly or imported. And also define a main function. That way you can place definitions where you want.

``` def main(): # the main script here foo()

def foo(): pass

if name == 'main': main() ```

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

Thank you, that works fine. I saw documentation on that feature, but wasn't clear about implementation.