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 >
Text File  |  1997-01-27  |  879b  |  27 lines

  1. import ni
  2. from win32com.server.exception import Exception
  3. import winerror
  4.  
  5. # Expose the Python interpreter.
  6. class Interpreter:
  7.     _public_methods_ = [ 'Exec', 'Eval' ]
  8.     def Eval(self, exp):
  9.         if type(exp)<>type(''):
  10.             raise Exception(desc="Must be a string",scode=winerror.DISP_E_TYPEMISMATCH)
  11.                 
  12.         return eval(exp)
  13.     def Exec(self, exp):
  14.         if type(exp)<>type(''):
  15.             raise Exception(desc="Must be a string",scode=winerror.DISP_E_TYPEMISMATCH)
  16.         exec exp
  17.  
  18. if __name__=='__main__':
  19.     print "Registering COM server..."
  20.     from win32com.server.register import RegisterServer
  21.     RegisterServer("{30BD3490-2632-11cf-AD5B-524153480001}",
  22.                        "win32com.servers.interp.Interpreter",
  23.                        "Python Interpreter",
  24.                        "Python.Interpreter",
  25.                        "Python.Interpreter.2")
  26.     print "Class registered."
  27.