Diff of /exports.ipynb [000000] .. [dc3c86]

Switch to unified view

a b/exports.ipynb
1
{
2
 "cells": [
3
  {
4
   "cell_type": "code",
5
   "execution_count": 1,
6
   "metadata": {},
7
   "outputs": [],
8
   "source": [
9
    "#export\n",
10
    "TEST = 'test'"
11
   ]
12
  },
13
  {
14
   "cell_type": "markdown",
15
   "metadata": {},
16
   "source": [
17
    "## Export"
18
   ]
19
  },
20
  {
21
   "cell_type": "code",
22
   "execution_count": 2,
23
   "metadata": {},
24
   "outputs": [
25
    {
26
     "name": "stdout",
27
     "output_type": "stream",
28
     "text": [
29
      "Converted exports.ipynb to exp/nb_exports.py\r\n"
30
     ]
31
    }
32
   ],
33
   "source": [
34
    "! python notebook2script.py exports.ipynb"
35
   ]
36
  },
37
  {
38
   "cell_type": "markdown",
39
   "metadata": {},
40
   "source": [
41
    "### How it works:"
42
   ]
43
  },
44
  {
45
   "cell_type": "code",
46
   "execution_count": 3,
47
   "metadata": {},
48
   "outputs": [],
49
   "source": [
50
    "import json\n",
51
    "d = json.load(open('exports.ipynb','r'))['cells']"
52
   ]
53
  },
54
  {
55
   "cell_type": "code",
56
   "execution_count": 4,
57
   "metadata": {},
58
   "outputs": [
59
    {
60
     "data": {
61
      "text/plain": [
62
       "{'cell_type': 'code',\n",
63
       " 'execution_count': 1,\n",
64
       " 'metadata': {},\n",
65
       " 'outputs': [],\n",
66
       " 'source': ['#export\\n', \"TEST = 'test'\"]}"
67
      ]
68
     },
69
     "execution_count": 4,
70
     "metadata": {},
71
     "output_type": "execute_result"
72
    }
73
   ],
74
   "source": [
75
    "d[0]"
76
   ]
77
  },
78
  {
79
   "cell_type": "code",
80
   "execution_count": 5,
81
   "metadata": {},
82
   "outputs": [
83
    {
84
     "data": {
85
      "text/plain": [
86
       "[\"TEST = 'test'\"]"
87
      ]
88
     },
89
     "execution_count": 5,
90
     "metadata": {},
91
     "output_type": "execute_result"
92
    }
93
   ],
94
   "source": [
95
    "d[0]['source'][1:]"
96
   ]
97
  },
98
  {
99
   "cell_type": "code",
100
   "execution_count": null,
101
   "metadata": {},
102
   "outputs": [],
103
   "source": []
104
  }
105
 ],
106
 "metadata": {
107
  "kernelspec": {
108
   "display_name": "Python 3",
109
   "language": "python",
110
   "name": "python3"
111
  },
112
  "language_info": {
113
   "codemirror_mode": {
114
    "name": "ipython",
115
    "version": 3
116
   },
117
   "file_extension": ".py",
118
   "mimetype": "text/x-python",
119
   "name": "python",
120
   "nbconvert_exporter": "python",
121
   "pygments_lexer": "ipython3",
122
   "version": "3.7.2"
123
  }
124
 },
125
 "nbformat": 4,
126
 "nbformat_minor": 2
127
}