Skip to content

Defining __getattr__ breaks _repr_html_ #2014

@mcleonard

Description

@mcleonard

I created a class where I am storing rows of data with column headers. I want to display the contents in an HTML table in notebooks, so I'm using _repr_html_. I'd also like to access columns using the headers as attributes, like foo.column1. However, defining __getattr__ stops _repr_html_ from being called and the notebook falls back to __repr__. This shouldn't happen because _repr_html_ is defined in the class instance, so __getattr__ shouldn't be called. I checked if __getattr__ is being called and it appears that _ipython_canary_method_should_not_exist_ is being called and then it falls back to the normal __repr__.

Here's an example:
screen shot 2016-12-24 at 5 48 26 pm

screen shot 2016-12-24 at 5 48 40 pm

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions