[IPython-dev] New display methods, should we fine-tune our naming decision?

Thomas Kluyver takowl at gmail.com
Tue Feb 1 14:33:05 EST 2011


On 1 February 2011 19:05, Brian Granger <ellisonbg at gmail.com> wrote:

> * Simplicity.  __html__ is easier to remember that __repr_html__.  I
> want writing these methods to be like eating candy.
>

I suppose the key question is: is it reasonable to expect that none of these
names will have another use? I can't off the top of my head think of any
reason that __html__ would produce anything but an HTML representation, and
likewise for __svg__ and __png__, but it's worth thinking about.

Hmm, actually... a tool which is building, say, an SVG document may have
methods on the components which produce fragments (SVG which is valid within
an SVG document, but isn't a document by itself). I've seen this with an
svg() method, although not with an __svg__() method. Can the display code
handle such fragments? How does it fall over if it attempts to display
invalid svg/html/etc.?

For collecting all possible repr-like methods, there could be an informal
standard to put them into something like __repr_methods__. But unless it has
a real world role, library writers will simply ignore it.

Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20110201/3bba18ba/attachment.html>


More information about the IPython-dev mailing list