belinda thom kirjoitti:
On Apr 25, 2007, at 12:46 PM, Bill Baxter wrote:
Agree w/most of what you've said, but will add one other thing that drives me nuts in python that hasn't been a problem in Matplotlib:
In Python, if interacting w/the interpreter as your primary IDE, and if you've got multiple files that depend on one another that you're modifying, then you need to restart the interpreter frequently b/c otherwise things in the interpreter can be stale; IOW, changes to several interdependent files aren't easy to import so that everything in your interpreted environment reflects the latest code. Yeah, there's reload tricks, but doing them in the right order and the right number of times can be a pain when dependencies are cyclic.
I realize in general that this issue of stale code is just difficult, that its not inherently a Python problem per se, for automatic percolation of code changes backwards in time is difficult in general, but I've never had the problem bite me when I was developing in Matlab. I just save whatever file, and it appears that whatever's latest on disk is what's executed. (Friends who know more about PL than I tell me I've been lucky.)
I've been using the attached autoreload code (by Thomas Heller, different versions are probably floating around the net) rather successfully for a more Matlabish feel to IPython. It reloads modules every time their files have been changed. Of course, this doesn't solve all staleness problems you describe, but only eliminates manual work involved in solving the most common ones. Reloading modules does have pitfalls [1], but at least in my use these haven't really mattered much in practice. I think having autoreload functionality bundled with IPython (maybe turned off per default) would be quite useful: although in some rare cases autoreloading doesn't work in the ideal way, it's very convenient not to have to type reload(foo) after every change, especially when tweaking for example plotting scripts. Pauli [1] For example, instances of classes created are not updated on reload, but continue using the old code. Also, from foo import * imports are not updated, so you'll have to manually touch files that do this if 'foo' has been changed.