from IPython.display import Markdown, display
display(Markdown('''
# Hi Dan
1. Thanks for fixing the last issue so quickly
1. This library is really cool
1. I'll probably start using it for work soon
'''))
from random import choice, seed
from string import ascii_lowercase
seed(0)
def _random_str(length: int):
return ''.join(choice(ascii_lowercase) for _ in range(length))
class RandomUser:
def __init__(self):
self.user = _random_str(10)
self.password = _random_str(20)
def _repr_html_(self):
return f'''
<table>
<tr><th>User: </th><td>{self.user}</td>
<tr><th>Password: </th><td>{self.password}</td>
</table>
'''
RandomUser()
User: | mynbiqpmzj |
---|---|
Password: | plsgqejeydtzirwztejd |
import json
class DisplayDict(dict):
def _repr_json_(self):
return self
DisplayDict({'hello': 'world'})
{'hello': 'world'}