Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Rename special display methods and put them lower in priority than display functions #291

Closed
ellisonbg opened this Issue · 11 comments

5 participants

@ellisonbg
Owner

Our new display system uses special methods like __html__, __latex__ to allow objects to declare their representations. We need to rethink how we want to name these methods. Soe ideas are: __repr_html__, __disp_html__, etc.

R. Kern also suggested that these special methods are used after global display functions are attempted.

@rkern

I also suggest that they not use the __double_underscores__ that are reserved for the Python language itself. :-)

@fperez
Owner

@ellisonbg, this is also on our immediate todo so I made it critical. We should have that protocol sorted out before release (I can also help on that).

@ellisonbg ellisonbg was assigned
@jasongrout

In the spirit of "Namespaces are one honking great idea -- let's do more of those!", how about prefixing these special ipython methods with an _ipython prefix? For example, I can see Sage having some other assumptions about an __html__ method. Maybe names like _ipython_html or _ipython_latex might make sense. Or maybe collecting these methods into an _ipython_pyout dictionary or object would make sense, so that myvar._ipython_pyout['latex'] or myvar._ipython_pyout.latex would be the ipython latex-formatting function.

@ellisonbg
Owner
@jasongrout

Or here's another idea: _ipython_repr(format='json') or _ipython_repr(format='latex')

@takluyver
Owner

Or, one thing that was suggested before, have a dictionary of mimetype -> method, so we could do:

thing._ipython_repr['text/html']().

This also makes it easy to replace the methods at runtime. The difficulty is that the method references in the dictionary won't be automatically bound on instantiation, so we'd have to find a neat way of handling it.

@ellisonbg
Owner
@ellisonbg
Owner

This is merged.

@ellisonbg
Owner

Closing...

@ellisonbg ellisonbg closed this
@jasongrout

What is merged? Do you happen to have a link to the commit(s)?

@ellisonbg
Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.