display messages in python shell

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Mon Nov 19 20:09:15 CET 2007


Jens a écrit :
> On 19 Nov., 19:48, kou... at hotmail.com wrote:
> 
>>Is it possible to display messages in the python shell?  I want to
>>display error messages based on parameters in my scripts to the
>>users.  Is there another way to display messages other than log
>>files?  Thanks.
>>
>>Kou
> 
> 
> What about using print? For example:
> 
> print "This is a message."

print writes to stdout - which is for normal program outputs. wrt/ 
errors, you want stderr, ie:

import sys

print >> sys.sdterr, "this is an error message"

HTH



More information about the Python-list mailing list