[IPython-dev] Output of, e.g., type(a)

Warren Weckesser warren.weckesser@enthought....
Sat Oct 22 14:20:40 CDT 2011


On Sat, Oct 22, 2011 at 1:36 PM, Robert Kern <robert.kern@gmail.com> wrote:

> On 10/22/11 6:58 PM, Warren Weckesser wrote:
> >
> >
> > On Sat, Oct 22, 2011 at 12:49 PM, Warren Weckesser
> > <warren.weckesser@enthought.com <mailto:warren.weckesser@enthought.com>>
> wrote:
> >
> >     Hi all,
> >
> >     ipython is doing some magic with the output of 'type(a)' (using
> 0.11.rc1 in
> >     EPD):
> >
> >     In [1]: a = 1
> >
> >     In [2]: type(a)
> >     Out[2]: int
> >
> >     In [3]: str(type(a))
> >     Out[3]: "<type 'int'>"
> >
> >     In [4]: repr(type(a))
> >     Out[4]: "<type 'int'>"
> >
> >     The output in line 2 is nicer, but it makes it appear that the
> builtin
> >     'type' behaves in a way that it does not.  My attempts (possibly too
> brief)
> >     to find documentation or discussion of this feature have not been
> fruitful.
> >     Can anyone point me to the relevant docs, or mailing list
> discussions?  Thanks.
> >
> >
> >
> > Of course, three minutes after sending that email, I find the '%pprint'
> command
> > for toggling pretty-printing.  That's enough to answer my question.
>
> The default pretty-printers are defined starting here:
>
>
> https://github.com/ipython/ipython/blob/master/IPython/lib/pretty.py#L463
>
> These were the defaults for the upstream, third-party pretty.py (with a
> just a
> bug-fix for the re objects, IIRC). I happen to like this one, but if there
> is a
> consensus that it is more confusing than pretty, I'm happy to consider
> changing it.
>


It's fine by me, now that I know it is just one of the pretty-printing
hooks.

Warren



> --
> 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-dev mailing list
> IPython-dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-dev/attachments/20111022/3c59bedf/attachment-0001.html 


More information about the IPython-dev mailing list