title: How does django's `python manage.py shell` keep the command prompt open?
body: <p>When you run <code>python manage.py shell</code>, (or <code>shell_plus</code> if you have the extension), the script will import some stuff for you and then open a regular python shell for you to try commands out, as opposed to running the script and immediately closing.</p>
  <p>I know that you can use the <code>-i</code> switch when calling a script to keep the command prompt open, for example <code>python -i foo.py</code> will run the contents of <code>foo.py</code> yet keep the shell open instead of immediately closing.</p>
  <p>I would guess that when you call django's <code>manage.py shell</code> it somehow uses the same feature to get the command prompt to stay open and not immediately close out.</p>
  <p>How does it work? Can I add something to any script file to make it behave the same way (without using the <code>-i</code> switch) ?</p>