├── setup.cfg ├── pretty-context.png ├── .travis.yml ├── setup.py ├── disp ├── spark.py ├── __init__.py ├── vendor.py └── py3only.py ├── LICENSE ├── README.md ├── .gitignore └── example └── Disp-Example-builtins.ipynb /setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal=1 3 | -------------------------------------------------------------------------------- /pretty-context.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipython/disp/master/pretty-context.png -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | sudo: false 3 | before_install: 4 | - pip install pip --upgrade 5 | - pip install ipython 6 | script: 7 | - ipython -c 'import disp; disp.install()' 8 | - # py.test # no test for now. 9 | - ipython -c 'import disp; disp.uninstall()' 10 | python: 11 | - "nightly" 12 | - 3.6-dev 13 | - 3.6 14 | - 3.5 15 | - 2.7 16 | 17 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | description='Providing default representations of common objects in Python land', 4 | 5 | try: 6 | import pypandoc 7 | description = pypandoc.convert(open('README.md','r').read(), format='markdown', to='rst') 8 | except: 9 | print('Issues running or importing pypandoc. If you are publishing the package the description will be missing.') 10 | 11 | setup(name='disp', 12 | version='0.0.3', 13 | description='Providing default representations of common objects in Python land', 14 | url='http://github.com/ipython/disp', 15 | author='IPython developers', 16 | author_email='ipython-dev@python.org', 17 | license='BSD', 18 | packages=['disp'], 19 | zip_safe=False) 20 | -------------------------------------------------------------------------------- /disp/spark.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | def fully_qualified_name(m): 6 | return (m.__module__ + "." if hasattr(m, "__module__") else "") + m.__class__.__name__ 7 | 8 | 9 | def repr_spark_context_html(sc): 10 | ''' 11 | Carry over from the Spark 2.2.0 _repr_html_ for spark contexts 12 | 13 | Works on objects whose fully qualified name is 'pyspark.context.SparkContext' 14 | ''' 15 | return """ 16 |
SparkContext
18 | 19 | 20 | 21 |v{sc.version}{sc.master}{sc.appName}SparkSession - {catalogImplementation}
44 | {sc_HTML} 45 |{escape(string)}")
172 |
173 |
174 | def well(s):
175 | s = safe(s)._repr_html_()
176 | return HTML('{delims[1]}
204 |{escape(repr(req))}{escape(repr(req))}{escape(repr(obj))}
295 | """
296 |
297 |
298 | def general_repr(obj):
299 | return f'' +\
300 | f'{escape(repr(obj))}
' +\
301 | _inner_html_formatter_for_mapping({k: v for (k, v) in vars(obj).items() if not k.startswith('_')}) +\
302 | ''
303 |
304 |
305 | def html_formatter_for_type(obj):
306 | try:
307 | mro = obj.mro() # [o for o in if o is not object]
308 | except TypeError:
309 | mro = ()
310 | if len(mro) > 1:
311 | mime = get_repr_mimebundle(mro[1], include='text/html').data
312 | return f'' + \
313 | f'{escape(repr(obj))}
'\
314 | + well(HTML(f"""
315 | {obj.__doc__ or ''}
316 | Inherit from :
317 |
318 | - {mime.get('text/html')}
319 |
"""))._repr_html_()\
320 | + ''
321 | else:
322 | return f'' + f'{escape(repr(obj))}'
323 |
324 |
325 | def html_formatter_for_builtin_function_or_method(obj):
326 | ip = get_ipython()
327 | res = {k: v for (k, v) in ip.inspector.info(obj).items() if v}
328 | docstring = res.get('docstring')
329 | res.pop('found')
330 | res.pop('string_form')
331 | res.pop('base_class')
332 | if res.get('definition', None):
333 | res['definition'] = code(obj.__name__ + res['definition'])
334 | if docstring != '':
335 | res['docstring'] = code(docstring)
336 | else:
337 | del res['docstring']
338 | return f'' + htmlify_repr(details(code(repr(obj)), well(HTML(_inner_html_formatter_for_mapping(res)))))
339 |
340 |
341 | def html_formatter_for_module(obj):
342 | return f'' + details(code(repr(obj)), well(code(obj.__doc__ or '')))._repr_html_()
343 |
--------------------------------------------------------------------------------
/example/Disp-Example-builtins.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# Disp Example"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "This is an example on how you can use disp to make the environement you use richer."
15 | ]
16 | },
17 | {
18 | "cell_type": "markdown",
19 | "metadata": {},
20 | "source": [
21 | "Let's have a quick look at a nor mal workflow, and how objects are show in the notebook: "
22 | ]
23 | },
24 | {
25 | "cell_type": "code",
26 | "execution_count": 1,
27 | "metadata": {},
28 | "outputs": [
29 | {
30 | "data": {
31 | "text/plain": [
32 | "IPython.core.interactiveshell.InteractiveShell"
33 | ]
34 | },
35 | "execution_count": 1,
36 | "metadata": {},
37 | "output_type": "execute_result"
38 | }
39 | ],
40 | "source": [
41 | "from IPython.terminal.interactiveshell import InteractiveShell\n",
42 | "import disp\n",
43 | "InteractiveShell"
44 | ]
45 | },
46 | {
47 | "cell_type": "code",
48 | "execution_count": 2,
49 | "metadata": {},
50 | "outputs": [
51 | {
52 | "data": {
53 | "text/plain": [
54 | ""
55 | ]
56 | },
57 | "execution_count": 2,
58 | "metadata": {},
59 | "output_type": "execute_result"
60 | }
61 | ],
62 | "source": [
63 | "print"
64 | ]
65 | },
66 | {
67 | "cell_type": "code",
68 | "execution_count": 3,
69 | "metadata": {},
70 | "outputs": [
71 | {
72 | "data": {
73 | "text/plain": [
74 | ""
75 | ]
76 | },
77 | "execution_count": 3,
78 | "metadata": {},
79 | "output_type": "execute_result"
80 | }
81 | ],
82 | "source": [
83 | "disp"
84 | ]
85 | },
86 | {
87 | "cell_type": "markdown",
88 | "metadata": {},
89 | "source": [
90 | "This is a bit boring, and not always informative. Let's enable disp for builtin types. We don't do it by default, as it can be heavily computation intensive and does nto work outside of IPython. It will also make your notebook files way larger. "
91 | ]
92 | },
93 | {
94 | "cell_type": "code",
95 | "execution_count": 4,
96 | "metadata": {},
97 | "outputs": [],
98 | "source": [
99 | "import disp\n",
100 | "disp.activate_builtins()"
101 | ]
102 | },
103 | {
104 | "cell_type": "markdown",
105 | "metadata": {},
106 | "source": [
107 | "Let's have a look again at previous objects:"
108 | ]
109 | },
110 | {
111 | "cell_type": "code",
112 | "execution_count": 5,
113 | "metadata": {},
114 | "outputs": [
115 | {
116 | "data": {
117 | "text/html": [
118 | "IPython.core.interactiveshell.InteractiveShell
\n",
212 | " An enhanced, interactive shell for Python.
\n",
213 | " Inherit from :
\n",
214 | " \n",
215 | " traitlets.config.configurable.SingletonConfigurable
\n",
309 | " A configurable that only allows one instance.\n",
310 | "\n",
311 | " This class is for classes that should only have one instance of itself\n",
312 | " or *any* subclass. To create and retrieve such a class use the\n",
313 | " :meth:`SingletonConfigurable.instance` method.\n",
314 | "
\n",
315 | " Inherit from :
\n",
316 | " \n",
317 | " traitlets.config.configurable.LoggingConfigurable
\n",
411 | " A parent class for Configurables that log.\n",
412 | "\n",
413 | " Subclasses have a log trait, and the default behavior\n",
414 | " is to get the logger from the currently running Application.\n",
415 | "
\n",
416 | " Inherit from :
\n",
417 | " \n",
418 | " traitlets.config.configurable.Configurable
\n",
512 | "
\n",
513 | " Inherit from :
\n",
514 | " \n",
515 | " traitlets.traitlets.HasTraits
\n",
609 | "
\n",
610 | " Inherit from :
\n",
611 | " \n",
612 | " traitlets.traitlets.HasDescriptors
\n",
706 | " The base class for all classes that have descriptors.\n",
707 | "
\n",
708 | " Inherit from :
\n",
709 | " \n",
710 | " - None
\n",
711 | "
\n",
712 | "
\n",
713 | "
\n",
714 | "
\n",
715 | "
\n",
716 | "
"
717 | ],
718 | "text/plain": [
719 | "IPython.core.interactiveshell.InteractiveShell"
720 | ]
721 | },
722 | "execution_count": 5,
723 | "metadata": {},
724 | "output_type": "execute_result"
725 | }
726 | ],
727 | "source": [
728 | "InteractiveShell"
729 | ]
730 | },
731 | {
732 | "cell_type": "markdown",
733 | "metadata": {},
734 | "source": [
735 | "You should see now (at least if you are in an interactive environement) a small triangle in front of `IPython.core.interactiveshell.InteractiveShell`, if you click on it, the output will expand to show you the documentation as well as the inheritence (Actually the MRO... but details for now)."
736 | ]
737 | },
738 | {
739 | "cell_type": "code",
740 | "execution_count": 6,
741 | "metadata": {},
742 | "outputs": [
743 | {
744 | "data": {
745 | "text/html": [
746 | "<function print>
\n",
840 | " - type_name:
\n",
841 | " - 'builtin_function_or_method'
\n",
842 | "
\n",
843 | " \n",
844 | " - docstring:
\n",
845 | " print(value, ..., sep=' ', end='\\n', file=sys.stdout, flush=False)\n",
846 | "\n",
847 | "Prints the values to a stream, or to sys.stdout by default.\n",
848 | "Optional keyword arguments:\n",
849 | "file: a file-like object (stream); defaults to the current sys.stdout.\n",
850 | "sep: string inserted between values, default a space.\n",
851 | "end: string appended after the last value, default a newline.\n",
852 | "flush: whether to forcibly flush the stream. \n",
853 | "
\n",
854 | " "
855 | ],
856 | "text/plain": [
857 | ""
858 | ]
859 | },
860 | "execution_count": 6,
861 | "metadata": {},
862 | "output_type": "execute_result"
863 | }
864 | ],
865 | "source": [
866 | "print"
867 | ]
868 | },
869 | {
870 | "cell_type": "markdown",
871 | "metadata": {},
872 | "source": [
873 | "Print wil have the same treatment, with an overview of the documetation. You can still use `?`/`??` to get more information. "
874 | ]
875 | },
876 | {
877 | "cell_type": "code",
878 | "execution_count": 7,
879 | "metadata": {},
880 | "outputs": [
881 | {
882 | "data": {
883 | "text/html": [
884 | "<module 'disp' from '/Users/bussonniermatthias/dev/disp/disp/__init__.py'>
\n",
978 | "Rich display for a variety of Python objects.\n",
979 | "\n",
980 | "Use the followign to enable permanently.\n",
981 | "\n",
982 | ">>> import disp; disp.install()\n",
983 | "\n",
984 | "\n",
985 | "The following activate rich repr on a couple of builtins types:\n",
986 | "\n",
987 | " - functions/methods\n",
988 | " - types\n",
989 | " - modules\n",
990 | "\n",
991 | ">>> import disp; disp.activate_builtins()\n",
992 | "\n",
993 | "As this may have side-effect the setting does not persist across sessions\n",
994 | "\n",
995 | "\n",
996 | "Some object are not enabled by default, you can activate with:\n",
997 | "\n",
998 | ">>> import disp; disp.activate_for(something)\n",
999 | "\n",
1000 | "For example, a `requests`'s response. \n",
1001 | "\n",
1002 | ">>> import requests\n",
1003 | ">>> response = requests.get(...)\n",
1004 | ">>> disp.activate+for(response)\n",
1005 | ">>> response\n",
1006 | "\n",
1007 | "\n",
1008 | ""
1009 | ],
1010 | "text/plain": [
1011 | ""
1012 | ]
1013 | },
1014 | "execution_count": 7,
1015 | "metadata": {},
1016 | "output_type": "execute_result"
1017 | }
1018 | ],
1019 | "source": [
1020 | "disp"
1021 | ]
1022 | },
1023 | {
1024 | "cell_type": "markdown",
1025 | "metadata": {},
1026 | "source": [
1027 | "If modules have docstrings, they will be shown as well. "
1028 | ]
1029 | },
1030 | {
1031 | "cell_type": "markdown",
1032 | "metadata": {},
1033 | "source": [
1034 | "## Requests"
1035 | ]
1036 | },
1037 | {
1038 | "cell_type": "markdown",
1039 | "metadata": {},
1040 | "source": [
1041 | "Above are generic objects, `disp` also have special casing for some objects, example `requests` replies. "
1042 | ]
1043 | },
1044 | {
1045 | "cell_type": "code",
1046 | "execution_count": 8,
1047 | "metadata": {},
1048 | "outputs": [],
1049 | "source": [
1050 | "import requests\n",
1051 | "import requests_cache\n",
1052 | "requests_cache.install_cache('tmpcache.db')\n",
1053 | "\n",
1054 | "res = requests.get('https://api.github.com/aoisehgd')"
1055 | ]
1056 | },
1057 | {
1058 | "cell_type": "markdown",
1059 | "metadata": {},
1060 | "source": [
1061 | "`get` is still a generic function, so will show its doc:"
1062 | ]
1063 | },
1064 | {
1065 | "cell_type": "code",
1066 | "execution_count": 9,
1067 | "metadata": {},
1068 | "outputs": [
1069 | {
1070 | "data": {
1071 | "text/html": [
1072 | "<function requests.api.get>
\n",
1166 | " - type_name:
\n",
1167 | " - 'function'
\n",
1168 | "
\n",
1169 | " \n",
1170 | " - file:
\n",
1171 | " - '~/anaconda/lib/python3.6/site-packages/requests/api.py'
\n",
1172 | "
\n",
1173 | " \n",
1174 | " - definition:
\n",
1175 | " get(url, params=None, **kwargs) \n",
1176 | "
\n",
1177 | " \n",
1178 | " - docstring:
\n",
1179 | " Sends a GET request.\n",
1180 | "\n",
1181 | ":param url: URL for the new :class:`Request` object.\n",
1182 | ":param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`.\n",
1183 | ":param \\*\\*kwargs: Optional arguments that ``request`` takes.\n",
1184 | ":return: :class:`Response <Response>` object\n",
1185 | ":rtype: requests.Response \n",
1186 | "
\n",
1187 | " \n",
1188 | " - argspec:
\n",
1189 | " - {'annotations': {},\n",
1190 | " 'args': ['url', 'params'],\n",
1191 | " 'defaults': (None,),\n",
1192 | " 'kwonlyargs': [],\n",
1193 | " 'kwonlydefaults': None,\n",
1194 | " 'varargs': None,\n",
1195 | " 'varkw': 'kwargs'}
\n",
1196 | "
\n",
1197 | " "
1198 | ],
1199 | "text/plain": [
1200 | ""
1201 | ]
1202 | },
1203 | "execution_count": 9,
1204 | "metadata": {},
1205 | "output_type": "execute_result"
1206 | }
1207 | ],
1208 | "source": [
1209 | "requests.get # this is a function, alerady covered by activate_builtins()"
1210 | ]
1211 | },
1212 | {
1213 | "cell_type": "markdown",
1214 | "metadata": {},
1215 | "source": [
1216 | "By default again the repr is not enabled:"
1217 | ]
1218 | },
1219 | {
1220 | "cell_type": "code",
1221 | "execution_count": 10,
1222 | "metadata": {},
1223 | "outputs": [
1224 | {
1225 | "data": {
1226 | "text/plain": [
1227 | ""
1228 | ]
1229 | },
1230 | "execution_count": 10,
1231 | "metadata": {},
1232 | "output_type": "execute_result"
1233 | }
1234 | ],
1235 | "source": [
1236 | "res"
1237 | ]
1238 | },
1239 | {
1240 | "cell_type": "code",
1241 | "execution_count": 11,
1242 | "metadata": {},
1243 | "outputs": [
1244 | {
1245 | "data": {
1246 | "text/html": [
1247 | "requests.models.Response
\n",
1341 | " The :class:`Response ` object, which contains a\n",
1342 | " server's response to an HTTP request.\n",
1343 | "
\n",
1344 | " Inherit from :
\n",
1345 | " \n",
1346 | " - None
\n",
1347 | "
"
1348 | ],
1349 | "text/plain": [
1350 | "requests.models.Response"
1351 | ]
1352 | },
1353 | "execution_count": 11,
1354 | "metadata": {},
1355 | "output_type": "execute_result"
1356 | }
1357 | ],
1358 | "source": [
1359 | "type(res) # this is a type, already cover by activate_builtins()"
1360 | ]
1361 | },
1362 | {
1363 | "cell_type": "markdown",
1364 | "metadata": {},
1365 | "source": [
1366 | "let's activate it:"
1367 | ]
1368 | },
1369 | {
1370 | "cell_type": "code",
1371 | "execution_count": 12,
1372 | "metadata": {},
1373 | "outputs": [],
1374 | "source": [
1375 | "disp.activate_for(res) # install for res (actually for type(res), but we infer that if what is given is an instance)"
1376 | ]
1377 | },
1378 | {
1379 | "cell_type": "code",
1380 | "execution_count": 13,
1381 | "metadata": {
1382 | "scrolled": false
1383 | },
1384 | "outputs": [
1385 | {
1386 | "data": {
1387 | "text/html": [
1388 | "\n",
1389 | " \n",
1485 | " <Response [404]>
\n",
1486 | " \n",
1487 | " - status_code:
\n",
1488 | " - 404
\n",
1489 | "
\n",
1490 | " \n",
1491 | " - headers:
\n",
1492 | " - \n",
1493 | " \n",
1494 | "
{
\n",
1495 | " \n",
1496 | " - Date:
\n",
1497 | " - 'Mon, 19 Jun 2017 18:49:54 GMT'
\n",
1498 | "
\n",
1499 | " \n",
1500 | " - Content-Type:
\n",
1501 | " - 'application/json; charset=utf-8'
\n",
1502 | "
\n",
1503 | " \n",
1504 | " - Transfer-Encoding:
\n",
1505 | " - 'chunked'
\n",
1506 | "
\n",
1507 | " \n",
1508 | " - Server:
\n",
1509 | " - 'GitHub.com'
\n",
1510 | "
\n",
1511 | " \n",
1512 | " - Status:
\n",
1513 | " - '404 Not Found'
\n",
1514 | "
\n",
1515 | " \n",
1516 | " - X-RateLimit-Limit:
\n",
1517 | " - '60'
\n",
1518 | "
\n",
1519 | " \n",
1520 | " - X-RateLimit-Remaining:
\n",
1521 | " - '51'
\n",
1522 | "
\n",
1523 | " \n",
1524 | " - X-RateLimit-Reset:
\n",
1525 | " - '1497900396'
\n",
1526 | "
\n",
1527 | " \n",
1528 | " - X-GitHub-Media-Type:
\n",
1529 | " - 'github.v3; format=json'
\n",
1530 | "
\n",
1531 | " \n",
1532 | " - Access-Control-Expose-Headers:
\n",
1533 | " - 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'
\n",
1534 | "
\n",
1535 | " \n",
1536 | " - Access-Control-Allow-Origin:
\n",
1537 | " - '*'
\n",
1538 | "
\n",
1539 | " \n",
1540 | " - Content-Security-Policy:
\n",
1541 | " - "default-src 'none'"
\n",
1542 | "
\n",
1543 | " \n",
1544 | " - Strict-Transport-Security:
\n",
1545 | " - 'max-age=31536000; includeSubdomains; preload'
\n",
1546 | "
\n",
1547 | " \n",
1548 | " - X-Content-Type-Options:
\n",
1549 | " - 'nosniff'
\n",
1550 | "
\n",
1551 | " \n",
1552 | " - X-Frame-Options:
\n",
1553 | " - 'deny'
\n",
1554 | "
\n",
1555 | " \n",
1556 | " - X-XSS-Protection:
\n",
1557 | " - '1; mode=block'
\n",
1558 | "
\n",
1559 | " \n",
1560 | " - X-Runtime-rack:
\n",
1561 | " - '0.039253'
\n",
1562 | "
\n",
1563 | " \n",
1564 | " - Content-Encoding:
\n",
1565 | " - 'gzip'
\n",
1566 | "
\n",
1567 | " \n",
1568 | " - X-GitHub-Request-Id:
\n",
1569 | " - 'A624:B330:A1C5E3:CA86F4:59481CD1'
\n",
1570 | "
\n",
1571 | " \n",
1572 | " \n",
1573 | " }\n",
1574 | " \n",
1575 | "
\n",
1576 | " \n",
1577 | " - raw:
\n",
1578 | " - <requests.packages.urllib3.response.HTTPResponse at 0x10c4ac630>
\n",
1579 | "
\n",
1580 | " \n",
1581 | " - url:
\n",
1582 | " - 'https://api.github.com/aoisehgd'
\n",
1583 | "
\n",
1584 | " \n",
1585 | " - encoding:
\n",
1586 | " - 'utf-8'
\n",
1587 | "
\n",
1588 | " \n",
1589 | " - history:
\n",
1590 | " - []
\n",
1591 | "
\n",
1592 | " \n",
1593 | " - reason:
\n",
1594 | " - 'Not Found'
\n",
1595 | "
\n",
1596 | " \n",
1597 | " - cookies:
\n",
1598 | " - <RequestsCookieJar[]>
\n",
1599 | "
\n",
1600 | " \n",
1601 | " - elapsed:
\n",
1602 | " - datetime.timedelta(0, 0, 926297)
\n",
1603 | "
\n",
1604 | " \n",
1605 | " - request:
\n",
1606 | " - <PreparedRequest [GET]>
\n",
1607 | "
\n",
1608 | " \n",
1609 | " - connection:
\n",
1610 | " - <requests.adapters.HTTPAdapter at 0x10c478588>
\n",
1611 | "
\n",
1612 | " \n",
1613 | " - from_cache:
\n",
1614 | " - False
\n",
1615 | "
\n",
1616 | " \n",
1617 | " \n",
1618 | " Content (JSON)
\n",
1619 | " \n",
1620 | " - message:
\n",
1621 | " - 'Not Found'
\n",
1622 | "
\n",
1623 | " \n",
1624 | " - documentation_url:
\n",
1625 | " - 'https://developer.github.com/v3'
\n",
1626 | "
\n",
1627 | " \n",
1628 | " \n",
1629 | " \n",
1630 | " "
1631 | ],
1632 | "text/plain": [
1633 | ""
1634 | ]
1635 | },
1636 | "execution_count": 13,
1637 | "metadata": {},
1638 | "output_type": "execute_result"
1639 | }
1640 | ],
1641 | "source": [
1642 | "res"
1643 | ]
1644 | },
1645 | {
1646 | "cell_type": "markdown",
1647 | "metadata": {},
1648 | "source": [
1649 | "We know have 1 click access to the content (if json), neatly formatted, and collapsible. we also have special cased the header field."
1650 | ]
1651 | },
1652 | {
1653 | "cell_type": "markdown",
1654 | "metadata": {},
1655 | "source": [
1656 | "## Beta feature"
1657 | ]
1658 | },
1659 | {
1660 | "cell_type": "markdown",
1661 | "metadata": {},
1662 | "source": [
1663 | "you can actually activate rich display for arbitrary container (making them collapsible), though this can have nasty side effects, so use at your own risk:"
1664 | ]
1665 | },
1666 | {
1667 | "cell_type": "code",
1668 | "execution_count": 14,
1669 | "metadata": {},
1670 | "outputs": [],
1671 | "source": [
1672 | "from IPython.display import HTML"
1673 | ]
1674 | },
1675 | {
1676 | "cell_type": "code",
1677 | "execution_count": 15,
1678 | "metadata": {},
1679 | "outputs": [
1680 | {
1681 | "data": {
1682 | "text/plain": [
1683 | "({},\n",
1684 | " ,\n",
1685 | " IPython.display.HTML,\n",
1686 | " [{'This is a key': 'and its value', 'hello': 'world'}, 123456789],\n",
1687 | " ,\n",
1688 | " set())"
1689 | ]
1690 | },
1691 | "execution_count": 15,
1692 | "metadata": {},
1693 | "output_type": "execute_result"
1694 | }
1695 | ],
1696 | "source": [
1697 | "ex = ({}, print, HTML, [{'hello':'world','This is a key':'and its value'}, 123456789], HTML('BOLD'), set())\n",
1698 | "ex"
1699 | ]
1700 | },
1701 | {
1702 | "cell_type": "code",
1703 | "execution_count": 16,
1704 | "metadata": {},
1705 | "outputs": [],
1706 | "source": [
1707 | "disp.activate_for(list)\n",
1708 | "disp.activate_for(tuple)\n",
1709 | "disp.activate_for(set)\n",
1710 | "disp.activate_for(dict)"
1711 | ]
1712 | },
1713 | {
1714 | "cell_type": "code",
1715 | "execution_count": 17,
1716 | "metadata": {},
1717 | "outputs": [
1718 | {
1719 | "data": {
1720 | "text/html": [
1721 | "\n",
1722 | " \n",
1723 | " (
\n",
1724 | " - dict({}),
<function print>
\n",
1818 | " - type_name:
\n",
1819 | " - 'builtin_function_or_method'
\n",
1820 | "
\n",
1821 | " \n",
1822 | " - docstring:
\n",
1823 | " print(value, ..., sep=' ', end='\\n', file=sys.stdout, flush=False)\n",
1824 | "\n",
1825 | "Prints the values to a stream, or to sys.stdout by default.\n",
1826 | "Optional keyword arguments:\n",
1827 | "file: a file-like object (stream); defaults to the current sys.stdout.\n",
1828 | "sep: string inserted between values, default a space.\n",
1829 | "end: string appended after the last value, default a newline.\n",
1830 | "flush: whether to forcibly flush the stream. \n",
1831 | "
\n",
1832 | " ,IPython.display.HTML
\n",
1926 | "
\n",
1927 | " Inherit from :
\n",
1928 | " \n",
1929 | " IPython.display.TextDisplayObject
\n",
2023 | " Validate that display data is text
\n",
2024 | " Inherit from :
\n",
2025 | " \n",
2026 | " IPython.display.DisplayObject
\n",
2120 | " An object that wraps data to be displayed.
\n",
2121 | " Inherit from :
\n",
2122 | " \n",
2123 | " - None
\n",
2124 | "
\n",
2125 | "
\n",
2126 | "
,\n",
2127 | " \n",
2128 | " [
\n",
2129 | " - \n",
2130 | " \n",
2131 | "
{
\n",
2132 | " \n",
2133 | " - hello:
\n",
2134 | " - 'world'
\n",
2135 | "
\n",
2136 | " \n",
2137 | " - This is a key:
\n",
2138 | " - 'and its value'
\n",
2139 | "
\n",
2140 | " \n",
2141 | " \n",
2142 | " }\n",
2143 | " , - 123456789
\n",
2144 | " \n",
2145 | " ]
\n",
2146 | "
\n",
2147 | "\n",
2148 | " ,- BOLD,
- set({})
\n",
2149 | " \n",
2150 | " )
\n",
2151 | "
\n",
2152 | "\n",
2153 | " "
2154 | ],
2155 | "text/plain": [
2156 | "({},\n",
2157 | " ,\n",
2158 | " IPython.display.HTML,\n",
2159 | " [{'This is a key': 'and its value', 'hello': 'world'}, 123456789],\n",
2160 | " ,\n",
2161 | " set())"
2162 | ]
2163 | },
2164 | "execution_count": 17,
2165 | "metadata": {},
2166 | "output_type": "execute_result"
2167 | }
2168 | ],
2169 | "source": [
2170 | "ex"
2171 | ]
2172 | }
2173 | ],
2174 | "metadata": {
2175 | "kernel_info": {
2176 | "name": "pythonroot"
2177 | },
2178 | "kernelspec": {
2179 | "display_name": "PythonRoot",
2180 | "language": "python",
2181 | "name": "pythonroot"
2182 | },
2183 | "language_info": {
2184 | "codemirror_mode": {
2185 | "name": "ipython",
2186 | "version": 3
2187 | },
2188 | "file_extension": ".py",
2189 | "mimetype": "text/x-python",
2190 | "name": "python",
2191 | "nbconvert_exporter": "python",
2192 | "pygments_lexer": "ipython3",
2193 | "version": "3.6.0"
2194 | }
2195 | },
2196 | "nbformat": 4,
2197 | "nbformat_minor": 2
2198 | }
2199 |
--------------------------------------------------------------------------------