DCOracle + Python Question

Dave Kuhlman dkuhlman at rexx.com
Wed Jan 17 17:23:40 EST 2001


If DCOracle is writing to either stdout or stderr, then look at the
description of stdout and stderr in the sys module described at:

    http://www.python.org/doc/current/lib/module-sys.html

in order to learn how to either re-route or throw away that output.


Basicaly, you define a class containing a "write" method taking one
parameter (the input string).  Then, assign an instance of this
class to sys.stdout or sys.stderr.

An example that hides error messages, then restores them:



>>> class MyHandler:
...     def write(self, msg):
...         pass
...
>>> import sys
>>> savehandler = sys.stderr
>>> sys.stderr = MyHandler()
>>> a = x
>>> a = y
>>> sys.stderr = savehandler
>>> a = x
Traceback (innermost last):
  File "<console>", line 1, in ?
NameError: x



  - Dave


Jose Martin <joseamartin at venmex.com> wrote:
> 
>  try:
>            dbc=DCOracle.Connect(connectstring)
>  except: pass
> 
> 
> if an error occurs , i dont want to show the message in the screen.
> how can hide the error message.
> 
> 
> 
> 
> 
>       _    _
>      @  @
>          'J
>         ~^
> 
> 

-- 
Dave Kuhlman
dkuhlman at rexx.com



More information about the Python-list mailing list