home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
c't freeware shareware 1997
/
CT_SW_97.ISO
/
mac
/
Software
/
entwickl
/
win95
/
pythowin.exe
/
DATA.3
/
win32com
/
servers
/
interp.py
next >
Wrap
Text File
|
1997-01-27
|
879b
|
27 lines
import ni
from win32com.server.exception import Exception
import winerror
# Expose the Python interpreter.
class Interpreter:
_public_methods_ = [ 'Exec', 'Eval' ]
def Eval(self, exp):
if type(exp)<>type(''):
raise Exception(desc="Must be a string",scode=winerror.DISP_E_TYPEMISMATCH)
return eval(exp)
def Exec(self, exp):
if type(exp)<>type(''):
raise Exception(desc="Must be a string",scode=winerror.DISP_E_TYPEMISMATCH)
exec exp
if __name__=='__main__':
print "Registering COM server..."
from win32com.server.register import RegisterServer
RegisterServer("{30BD3490-2632-11cf-AD5B-524153480001}",
"win32com.servers.interp.Interpreter",
"Python Interpreter",
"Python.Interpreter",
"Python.Interpreter.2")
print "Class registered."