question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose a _simpler_ way to get raw object reprs

See original GitHub issue

This came up in several contexts, @mpacer for subfigure and @rgbkrk who want to have list(objects) have rich reprs.

We can’t call _repr_*_ recursively as it may not be defined (user custom reprs, or repr_mimebundle). and get_ipython().display_formatter.format is bit verbose/hidden.

I propose a small wrapper around get_ipython().display_formatter.format, which is exposed and return the repr of an object. It has to likely have some logic to check for re-entrancy (like repr pretty) and avoid recursion.

Thoughts ?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:27 (27 by maintainers)

github_iconTop GitHub Comments

1reaction
ellisonbgcommented, Jun 15, 2017

With JupyterLab we are working hard to provide a lot of clarity about what things are public APIs and which things are not. The approach (how it turned out) in the classic notebook was to have users directly modify the DOM and target our CSS classes in extensions. The difficulty with that is that essentially makes your DOM structure and CSS classes public APIs, which is overly constraining from a maintenance perspective. With Lab, our policy is that the DOM structure and CSS classes are entirely private. As Kyle mentioned, this type of thing also makes it difficult for other frontends to cover these cases.

I agree with Kyle that if we were to ever standardize on DOM structure or CSS classes, it would need to be in both specs (nbformat, message spec). However, I don’t think that is the best way to get something like this working across frontends. Some other options:

  • Just return application/json and let the tree renderer handle it.
  • Return HTML, but with its own well scoped CSS inline.
  • Create a new MIME type that we can all build renderers for.

I prefer any/all of these over the CSS class standardization.

On Wed, Jun 14, 2017 at 4:44 PM, Brian Granger ellisonbg@gmail.com wrote:

I am not in favor of standardizing CSS class names or DOM structures…out with kids will write more later…

On Wed, Jun 14, 2017 at 12:32 PM, Kyle Kelley notifications@github.com wrote:

Why in the spec ?

The text/html and application/javascript mimetypes have this implicit support / ability from the classic notebook that has been a bit of a pitfall with other frontends (especially as libraries code for it).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ipython/ipython/issues/10647#issuecomment-308534612, or mute the thread https://github.com/notifications/unsubscribe-auth/AABr0EX4k1HoJPtm2faP5UYJBXUVsLNlks5sEDU1gaJpZM4N03rG .

– Brian E. Granger Associate Professor of Physics and Data Science Cal Poly State University, San Luis Obispo @ellisonbg on Twitter and GitHub bgranger@calpoly.edu and ellisonbg@gmail.com

– Brian E. Granger Associate Professor of Physics and Data Science Cal Poly State University, San Luis Obispo @ellisonbg on Twitter and GitHub bgranger@calpoly.edu and ellisonbg@gmail.com

0reactions
Carreaucommented, Jun 19, 2017

With JupyterLab we are working hard to provide a lot of clarity about what things are public APIs and which things are not. The approach (how it turned out) in the classic notebook was to have users directly modify the DOM and target our CSS classes in extensions. The difficulty with that is that essentially makes your DOM structure and CSS classes public APIs, which is overly constraining from a maintenance perspective. With Lab, our policy is that the DOM structure and CSS classes are entirely private. As Kyle mentioned, this type of thing also makes it difficult for other frontends to cover these cases.

Thanks, I was not at all speaking of already existing class, currently existing DOM structures, or of Dom even structures created by the frontend. The above example cannot be rendered only by a tree rendered that handle json. Creating a new mimetype does not work either. And “Well scoped” css cannot work cleanly either with current architecture as each leaf node would have to display a duplicate of the 80 line css fixes to render identically on Lab/Nteract/Classic.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the difference between __str__ and __repr__?
The use of eval(repr(obj)) is a sanity test and a rule of thumb - if this recreates the original object correctly then you...
Read more >
Simple Effective Ways to Care for Skin Wounds and Incisions
Go to: DO NOT LET EXPOSED RAW TISSUES DRY AND DIE. KEEP RAW WOUNDS CLEAN AND GREASY. How to Clean Raw Wounds?
Read more >
Simple Object Designer – Expose data as API endpoints
With the Simple Object Designer, it's possible to expose data as API endpoints. Microsoft is working hard to make API endpoint the primary...
Read more >
How to Build a Simple REST API in PHP - Code
In this article, we'll build a simple demo application, which allows you to fetch a list of users from the MySQL database via...
Read more >
Secrets
A Secret is an object that contains a small amount of sensitive data such as a password, a token, or a key. Such...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found