title: python: how to tell if file executed as import vs. main script?
body: <p>I'm writing a python file <code>mylib.py</code></p>
  
  <p>I'd like mylib.py to do something based on <code>sys.argv</code> if it's being executed as a script. But if it's imported from some other script, I don't want it to do that.</p>
  
  <p>How can I tell if my python file is being imported or it's a main script?</p>
  
  <p>(I've seen how to do this before, but I forgot.)</p>