Created
July 3, 2013 04:55
-
-
Save minrk/5915531 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "ListOfStrings" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"class ListOfStrings(object):\n", | |
" def __init__(self, *strings):\n", | |
" self.strings = strings\n", | |
" \n", | |
" def _repr_html_(self):\n", | |
" return ''.join( [\n", | |
" \"<span class='listofstr'>%s</span>\" % s\n", | |
" for s in self.strings\n", | |
" ])\n", | |
" " | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 15 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"%%html\n", | |
"<style type='text/css'>\n", | |
"span.listofstr {\n", | |
" margin-left: 5px\n", | |
"}\n", | |
"</style>" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": [ | |
"<style type='text/css'>\n", | |
"span.listofstr {\n", | |
" margin-left: 5px\n", | |
"}\n", | |
"</style>" | |
], | |
"metadata": {}, | |
"output_type": "display_data", | |
"text": [ | |
"<IPython.core.display.HTML at 0x109bd2390>" | |
] | |
} | |
], | |
"prompt_number": 7 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"ListOfStrings(\"hi\", \"hello\", \"hello there\")" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": [ | |
"<span class='listofstr'>hi</span><span class='listofstr'>hello</span><span class='listofstr'>hello there</span>" | |
], | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 16, | |
"text": [ | |
"<__main__.ListOfStrings at 0x10a7c1150>" | |
] | |
} | |
], | |
"prompt_number": 16 | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment