Skip to content

Instantly share code, notes, and snippets.

@minrk
Created July 3, 2013 04:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minrk/5915531 to your computer and use it in GitHub Desktop.
Save minrk/5915531 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"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