Keeping Python loaded
Kragen Sitaker
kragen at pobox.com
Tue Nov 27 16:48:51 EST 2001
"Matt Gerrans" <mgerrans at ix.netcom.com> writes:
> Where do I find mod_python and mod_snake? I searched in my Python directory
> to no avail. Are they a part of Apache? Or Zope?
modpython lives at http://www.modpython.org/ and mod_snake lives at
http://modsnake.sourceforge.net/ --- they are both parts of Apache.
> One simple trick I was considering was to write a little Tkinter or wxPython
> UI that hangs out (keeping the engine running at all times) and just lets me
> name a script; it could then simply import it and call main(). Yes, this
> assumes there is a main(); I always have the "if __name__ == "__main__":
> main()" line at the end of my scripts, so they can all have the same entry
> point and can run stand-alone or be imported. This is not a very general
> solution, of course...
I just wrote this script, which might be a somewhat better solution
--- it's fairly general-purpose, but if your scripts look at sys.argv,
you'll have to set that first.
#!/usr/bin/python
def runscript(filename):
namespace = { '__name__': '__main__' }
execfile(filename, namespace)
return namespace
def main():
import sys
runscript(sys.argv[1])
if __name__ == '__main__': main()
HTH.
More information about the Python-list
mailing list