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

Robert Kern robert.kern at gmail.com
Tue Feb 1 17:24:40 EST 2011


On 2/1/11 1:32 PM, Alex Gaynor wrote:

> Be careful with __html__ (Django doesn't support it, I think all the others you
> named do), it's not really intended to handle HTML formatting of an object, but
> really just manage whether or not it's supposed to be escaped or not.

Right. It's a tool for frameworks/template libraries to implement internal 
SafeString/Markup/whatever objects, not for application/library authors to make 
HTML representations of their model objects. If a Jinja2 user is viewing a 
Markup object in IPython, they want to see "Markup(u'<p>foo</p>')", not an 
HTML-formatted "foo". The HTMLFormatter's behavior is undesirable, and I think 
this is a good reason to avoid using __html__, at least.

-- 
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




More information about the IPython-dev mailing list