IDLE - Customizing output format

Ilias Lazaridis ilias at lazaridis.com
Wed Sep 27 08:29:48 EDT 2006


Gabriel Genellina wrote:
> At Tuesday 26/9/2006 15:29, Ilias Lazaridis wrote:
>
> > >  >>> def f(obj):
> > >       print '    ' + repr(obj)
> > >
> > >  >>> sys.displayhook = f
> >
> >I've placed this code within /Lib/sitecustomize.py, but have one
> >strange result:
...
> > >>> t.sayHello()
> >Hello world
> >   : None

> >1st: "Hello world" comes still on the beginning.
> >2nd: I got this "None"

import sys
def f(obj):
    if obj:
        print '::: ' + repr(obj)
sys.displayhook = f

> The replacement should be a bit more complicated, taking None into
> account - see the original PEP for details
> http://www.python.org/dev/peps/pep-0217/
> And notice that this replaces the output of *evaluated* expressions,
> not any print statement executed inside your code.

Any simple solution for this?

I've looked a little at the code, but get immediately demotivated
seeing 72 files within a flat directroy:

http://svn.python.org/view/python/trunk/Lib/idlelib/?rev=52013

.

--
http://lazaridis.com




More information about the Python-list mailing list