IDLE - Customizing output format
Robert Kern
robert.kern at gmail.com
Tue Sep 26 14:47:08 EDT 2006
Ilias Lazaridis wrote:
> Robert Kern wrote:
>> Anyways, against my better judgement, I will tell you that you can customize the
>> output by replacing sys.displayhook with your own function:
>>
>> http://www.python.org/doc/current/lib/module-sys.html
>>
>> >>> import sys
>> >>> 1
>> 1
>> >>> def f(obj):
>> print ' ' + repr(obj)
>>
>> >>> sys.displayhook = f
>> >>> 1
>> 1
>> >>>
>
> I've placed this code within /Lib/sitecustomize.py, but have one
> strange result:
>
>>>> from talker import *
>>>> t = Talker()
>>>> t.sayHello
> : <bound method Talker.sayHello of <talker.Talker instance at
> 0x00DEA198>>
>>>> t.sayHello()
> Hello world
> : None
>
> 1st: "Hello world" comes still on the beginning.
Yes. Read the doc for sys.displayhook() and you will understand why.
> 2nd: I got this "None"
Yes. Read the doc for sys.displayhook() and you will understand why.
I did not give you an all-singing, all-dancing solution, just showed you that
you *can* customize the output that you said you wanted customized.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list
mailing list