For scripts intended to double as general purpose modules, Python developers will usually do:
```python
def some_useful_function():
    return 'foobar'

def main():
    blah blah

if __name__ == '__main__':
    main()
```

This way if someone were to import your module from another script, `main()` would not be executed.
```python
from your_module import some_useful_function
```
It will still get run however if you run the module directly.
```bash
python your_module.py
```