Maybe something along these lines (prompt when running, after exit manage() command). It does bring up the terminal window.

import os
def manage():
    s=' '
    print 'Finnish manage command by entering empty line.'
    while s<>'':
        os.chdir('d:\\Python Projects\mysite')
        if s: os.system('python '+s)

or you can use instead of os.system this Command from

class Command(object):
    """Run a command and capture it's output string, error string and exit status"""

    def __init__(self, command):
        self.command = command 

    def run(self, shell=True):
        import subprocess as sp
        process = sp.Popen(self.command, shell = shell, stdout = sp.PIPE, stderr = sp.PIPE) =
        self.output, self.error = process.communicate()
        self.failed = process.returncode
        return self

    def returncode(self):
        return self.failed

On Windows OS this behaves like double-clicking on the Python code file name ...

import os

I was thinking of something along the lines of Oracles ability to run SQL scripts from the SQL*Plus command line, like so:

SQL> start  script.sql  param1  param2

I guess what I'm asking is, if the Python command interpreter (and thereby PythonWin and IDLE) can do this:

>>>  syncdb

Edited 6 Years Ago by Soren Werk: n/a

The more primitive solution:

import os
def manage(s): os.system('python '+s)

## let's keep it working not only in windows

## after running this file you can use manage-command from IDLE command window
## but output goes to separate terminal window
This article has been dead for over six months. Start a new discussion instead.