Do you recommend using top level code or if __name__ == '__main__'? Why?

Gnarly details: sys — System-specific parameters and functions — Python 3.11.0 documentation

I only ever use it to return 0 (success), 1 (most failures), 2 (bad
invocation/usage) and occasionally other small nonzero ints if the
programme has a suite of defined failure modes.

Returning None (eg main() forgets an explicit return) is also like
returning 0.

Cheers,
Cameron Simpson cs@cskk.id.au