{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import test" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<h1>Test</h1>" | |
], | |
"text/plain": [ | |
"<test.Test at 0x7f646cd7e978>" | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"test.Test()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<style>\n", | |
" svg { border: 1px solid black;}\n", | |
"</style>\n", | |
"<svg width=\"512\" height=\"512\" viewBox=\"0 0 8 8\">\n", | |
" <rect x=\"0\" y=\"0\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"1\" y=\"0\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"2\" y=\"0\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"3\" y=\"0\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"4\" y=\"0\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"5\" y=\"0\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"6\" y=\"0\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"7\" y=\"0\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"0\" y=\"1\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"1\" y=\"1\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"2\" y=\"1\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"3\" y=\"1\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"4\" y=\"1\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"5\" y=\"1\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"6\" y=\"1\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"7\" y=\"1\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"0\" y=\"2\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"1\" y=\"2\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"2\" y=\"2\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"3\" y=\"2\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"4\" y=\"2\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"5\" y=\"2\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"6\" y=\"2\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"7\" y=\"2\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"0\" y=\"3\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"1\" y=\"3\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"2\" y=\"3\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"3\" y=\"3\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"4\" y=\"3\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"5\" y=\"3\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"6\" y=\"3\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"7\" y=\"3\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"0\" y=\"4\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"1\" y=\"4\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"2\" y=\"4\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"3\" y=\"4\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"4\" y=\"4\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"5\" y=\"4\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"6\" y=\"4\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"7\" y=\"4\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"0\" y=\"5\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"1\" y=\"5\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"2\" y=\"5\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"3\" y=\"5\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"4\" y=\"5\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"5\" y=\"5\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"6\" y=\"5\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"7\" y=\"5\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"0\" y=\"6\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"1\" y=\"6\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"2\" y=\"6\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"3\" y=\"6\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"4\" y=\"6\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"5\" y=\"6\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"6\" y=\"6\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"7\" y=\"6\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"0\" y=\"7\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"1\" y=\"7\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"2\" y=\"7\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"3\" y=\"7\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"4\" y=\"7\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"5\" y=\"7\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
" <rect x=\"6\" y=\"7\" width=\"1\" height=\"1\" fill=\"black\"/>\n", | |
" <rect x=\"7\" y=\"7\" width=\"1\" height=\"1\" fill=\"white\"/>\n", | |
"</svg>" | |
], | |
"text/plain": [ | |
"<test.ChessBoard at 0x7f646c39d240>" | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"test.ChessBoard()" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.5.2" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
import requests | |
class Test: | |
def _repr_html_(self): | |
return "<h1>Test</h1>" | |
class ChessBoard: | |
def _repr_html_(self): | |
url = 'https://gist.githubusercontent.com/ontouchstart/d753ff109f591995f399fe5425f0c005/raw/6d2b9e1e016cea1b0d4c1f793b4aa18e7dd53cac/chessboard.svg' | |
with requests.get(url) as response: | |
html = response.content.decode('utf-8') | |
return html |
This comment has been minimized.
This comment has been minimized.
You can also load the code to another notebook on Google Colab and play with it yourself. https://colab.research.google.com/gist/ontouchstart/934da948842bff86d470ffe25d692e67/test.ipynb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
This notebook can be viewed in
https://nbviewer.jupyter.org/gist/ontouchstart/ea1631f69e507a81a9d9ec56b79e4d11