IDLE - Customizing output format

Ilias Lazaridis ilias at lazaridis.com
Tue Sep 26 14:29:14 EDT 2006


Robert Kern wrote:
> Ilias Lazaridis wrote:
> > Steve Holden wrote:
>
> >> And I am wondering at your continual surprise when the rest of the world
> >> fails to share your perceptions. Doesn't this carry *any* information?
> >
> > not the rest of the world, but the rest of the python community.
>
> Remember back when you first came to comp.lang.python and I told you that this
> was not the community that you were looking for?
>
>    http://mail.python.org/pipermail/python-list/2005-February/266629.html
>
> Good times.

yes, good times, for the memory:

http://case.lazaridis.com/wiki/PythonAudit

but now I produce (using python):

http://dev.lazaridis.com/base

> 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.
2nd: I got this "None"


class Talker:
    def sayHello(self):
        print 'Hello world'
 
    def talk(self):
        self.sayHello()




More information about the Python-list mailing list