[IPython-User] Configure number formatter for integers?

Tobias Nöbauer tobias.noebauer@gmail....
Fri Mar 23 06:02:52 CDT 2012


ok, thanks. rtfm, and don't switch to matlab in between, makes you too
pass-by-value-dumb for python. for the record:

def my_int_pprinter(obj, p, cycle):
    return p.text('int: %g' % obj)

def my_long_pprinter(obj, p, cycle):
    return p.text('long: %g' % obj)

c.PlainTextFormatter.type_printers = {
type(1): my_int_pprinter,
type(1L): my_long_pprinter,
}

spring greetings from vienna (at)!
tobias



On 22 March 2012 17:05, Robert Kern <robert.kern@gmail.com> wrote:

> On 3/22/12 3:55 PM, Tobias Nöbauer wrote:
> > Hi all,
> >
> > I'm trying to make IPython 0.12 format large integers as '%g', i.e. in
> > floating point notation (I end up counting 0's all the time). I've
> > tried to configure c.PlainTextFormatter.type_printers and specify a
> > callable for the int type that does the job, like so (in
> > ipython_config.py):
> >
> > c.PlainTextFormatter.type_printers = {
> > type(1): (lambda x: '%g' % x)
> > }
> >
> > However, ipython tells me that this callable needs to take 3 arguments
> > as soon as I try to output an integer. Any clues where I can find docs
> > on the callable signature required here? Or am I on the wrong track?
> > Any clues?
>
> Also:
>
>
> http://ipython.org/ipython-doc/rel-0.12/api/generated/IPython.lib.pretty.html
>
> --
> 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
>
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20120323/0d18ef29/attachment.html 


More information about the IPython-User mailing list