Thank you. This is extremely helpful. The key that I was missing is that it's running them outside of the ipy context. I also discovered that if you call the script .ipy instead of .py, it actually does more or less what I was expecting -- that is, it allows magic commands, and I got the thing working as desired through this means.
I do appreciate the concern that my script should be "real" python, and I would aim for that eventually, but while I'm experimenting, it's useful to be able to have the interactive and script work the same way. I'm happy to "real-ify" it later. BTW, I generally work the opposite way than %edit: I code in emacs, and have a shell that's running ipy. Actually ipy is bad at this because it sends all sorts of terminal crap that I can probably get rid of somehow, but working this way has many advantages, not the least of which is that you don't have to fire up editors over and over (my editor context is primary), and I get an automatic log of my whole session in the shell buffer. This mode has served me well using regular python, because I didn't have the .ipy v. .py problem, but when I started into ipyton, things no longer worked. But your guidance (and others) have help deconfuse me on this. Thanks again!
-- https://mail.python.org/mailman/listinfo/python-list