summaryrefslogtreecommitdiff
path: root/notebooks/python/python_intro.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'notebooks/python/python_intro.ipynb')
-rw-r--r--notebooks/python/python_intro.ipynb260
1 files changed, 30 insertions, 230 deletions
diff --git a/notebooks/python/python_intro.ipynb b/notebooks/python/python_intro.ipynb
index 0168839..171b83c 100644
--- a/notebooks/python/python_intro.ipynb
+++ b/notebooks/python/python_intro.ipynb
@@ -62,7 +62,7 @@
62 }, 62 },
63 { 63 {
64 "cell_type": "code", 64 "cell_type": "code",
65 "execution_count": 50, 65 "execution_count": 12,
66 "id": "54c9e132-30b0-41bf-97e9-0e8b94f3d202", 66 "id": "54c9e132-30b0-41bf-97e9-0e8b94f3d202",
67 "metadata": {}, 67 "metadata": {},
68 "outputs": [], 68 "outputs": [],
@@ -109,7 +109,7 @@
109 }, 109 },
110 { 110 {
111 "cell_type": "code", 111 "cell_type": "code",
112 "execution_count": 51, 112 "execution_count": 13,
113 "id": "bd6134d9-cc0e-4b45-b6b3-50210f6395e2", 113 "id": "bd6134d9-cc0e-4b45-b6b3-50210f6395e2",
114 "metadata": {}, 114 "metadata": {},
115 "outputs": [], 115 "outputs": [],
@@ -140,7 +140,7 @@
140 }, 140 },
141 { 141 {
142 "cell_type": "code", 142 "cell_type": "code",
143 "execution_count": 52, 143 "execution_count": 14,
144 "id": "cd2b7f98-ea16-49e2-9d19-f37266bd4f3a", 144 "id": "cd2b7f98-ea16-49e2-9d19-f37266bd4f3a",
145 "metadata": {}, 145 "metadata": {},
146 "outputs": [ 146 "outputs": [
@@ -148,23 +148,7 @@
148 "name": "stdout", 148 "name": "stdout",
149 "output_type": "stream", 149 "output_type": "stream",
150 "text": [ 150 "text": [
151 "'can be written like this'\n" 151 "'can be written like this'\n",
152 ]
153 },
154 {
155 "data": {
156 "text/plain": [
157 "'foo bar'"
158 ]
159 },
160 "execution_count": 52,
161 "metadata": {},
162 "output_type": "execute_result"
163 },
164 {
165 "name": "stdout",
166 "output_type": "stream",
167 "text": [
168 "works just fine\n", 152 "works just fine\n",
169 "works\n", 153 "works\n",
170 "just\n", 154 "just\n",
@@ -174,110 +158,10 @@
174 { 158 {
175 "data": { 159 "data": {
176 "text/plain": [ 160 "text/plain": [
177 "'S'"
178 ]
179 },
180 "execution_count": 52,
181 "metadata": {},
182 "output_type": "execute_result"
183 },
184 {
185 "data": {
186 "text/plain": [
187 "'t'"
188 ]
189 },
190 "execution_count": 52,
191 "metadata": {},
192 "output_type": "execute_result"
193 },
194 {
195 "data": {
196 "text/plain": [
197 "'tatnett'"
198 ]
199 },
200 "execution_count": 52,
201 "metadata": {},
202 "output_type": "execute_result"
203 },
204 {
205 "data": {
206 "text/plain": [
207 "'tatnet'"
208 ]
209 },
210 "execution_count": 52,
211 "metadata": {},
212 "output_type": "execute_result"
213 },
214 {
215 "data": {
216 "text/plain": [
217 "'ett'"
218 ]
219 },
220 "execution_count": 52,
221 "metadata": {},
222 "output_type": "execute_result"
223 },
224 {
225 "data": {
226 "text/plain": [
227 "'tte'"
228 ]
229 },
230 "execution_count": 52,
231 "metadata": {},
232 "output_type": "execute_result"
233 },
234 {
235 "data": {
236 "text/plain": [
237 "True"
238 ]
239 },
240 "execution_count": 52,
241 "metadata": {},
242 "output_type": "execute_result"
243 },
244 {
245 "data": {
246 "text/plain": [
247 "False"
248 ]
249 },
250 "execution_count": 52,
251 "metadata": {},
252 "output_type": "execute_result"
253 },
254 {
255 "data": {
256 "text/plain": [
257 "True"
258 ]
259 },
260 "execution_count": 52,
261 "metadata": {},
262 "output_type": "execute_result"
263 },
264 {
265 "data": {
266 "text/plain": [
267 "b'B\\xc3\\x98!'"
268 ]
269 },
270 "execution_count": 52,
271 "metadata": {},
272 "output_type": "execute_result"
273 },
274 {
275 "data": {
276 "text/plain": [
277 "'BØ!'" 161 "'BØ!'"
278 ] 162 ]
279 }, 163 },
280 "execution_count": 52, 164 "execution_count": 14,
281 "metadata": {}, 165 "metadata": {},
282 "output_type": "execute_result" 166 "output_type": "execute_result"
283 } 167 }
@@ -520,87 +404,17 @@
520 }, 404 },
521 { 405 {
522 "cell_type": "code", 406 "cell_type": "code",
523 "execution_count": 53, 407 "execution_count": 15,
524 "id": "f4a4ea99-4038-4b61-9b8d-9ce623e6a663", 408 "id": "f4a4ea99-4038-4b61-9b8d-9ce623e6a663",
525 "metadata": {}, 409 "metadata": {},
526 "outputs": [ 410 "outputs": [
527 { 411 {
528 "data": { 412 "data": {
529 "text/plain": [ 413 "text/plain": [
530 "35082617072" 414 "-42990858669078524"
531 ]
532 },
533 "execution_count": 53,
534 "metadata": {},
535 "output_type": "execute_result"
536 },
537 {
538 "data": {
539 "text/plain": [
540 "35082617104"
541 ] 415 ]
542 }, 416 },
543 "execution_count": 53, 417 "execution_count": 15,
544 "metadata": {},
545 "output_type": "execute_result"
546 },
547 {
548 "data": {
549 "text/plain": [
550 "'H'"
551 ]
552 },
553 "execution_count": 53,
554 "metadata": {},
555 "output_type": "execute_result"
556 },
557 {
558 "data": {
559 "text/plain": [
560 "-6333845781340707986"
561 ]
562 },
563 "execution_count": 53,
564 "metadata": {},
565 "output_type": "execute_result"
566 },
567 {
568 "data": {
569 "text/plain": [
570 "36350585520"
571 ]
572 },
573 "execution_count": 53,
574 "metadata": {},
575 "output_type": "execute_result"
576 },
577 {
578 "data": {
579 "text/plain": [
580 "36350587520"
581 ]
582 },
583 "execution_count": 53,
584 "metadata": {},
585 "output_type": "execute_result"
586 },
587 {
588 "data": {
589 "text/plain": [
590 "8927089887582119463"
591 ]
592 },
593 "execution_count": 53,
594 "metadata": {},
595 "output_type": "execute_result"
596 },
597 {
598 "data": {
599 "text/plain": [
600 "8927089887582119463"
601 ]
602 },
603 "execution_count": 53,
604 "metadata": {}, 418 "metadata": {},
605 "output_type": "execute_result" 419 "output_type": "execute_result"
606 } 420 }
@@ -703,41 +517,15 @@
703 }, 517 },
704 { 518 {
705 "cell_type": "code", 519 "cell_type": "code",
706 "execution_count": 54, 520 "execution_count": 16,
707 "id": "bf95f44a-1257-440f-b35f-a8536c8c4363", 521 "id": "bf95f44a-1257-440f-b35f-a8536c8c4363",
708 "metadata": {}, 522 "metadata": {},
709 "outputs": [ 523 "outputs": [
710 { 524 {
711 "data": {
712 "text/plain": [
713 "7"
714 ]
715 },
716 "execution_count": 54,
717 "metadata": {},
718 "output_type": "execute_result"
719 },
720 {
721 "name": "stdout",
722 "output_type": "stream",
723 "text": [
724 "9\n"
725 ]
726 },
727 {
728 "data": {
729 "text/plain": [
730 "[9, -2]"
731 ]
732 },
733 "execution_count": 54,
734 "metadata": {},
735 "output_type": "execute_result"
736 },
737 {
738 "name": "stdout", 525 "name": "stdout",
739 "output_type": "stream", 526 "output_type": "stream",
740 "text": [ 527 "text": [
528 "9\n",
741 "[9, 5]\n" 529 "[9, 5]\n"
742 ] 530 ]
743 } 531 }
@@ -785,7 +573,7 @@
785 }, 573 },
786 { 574 {
787 "cell_type": "code", 575 "cell_type": "code",
788 "execution_count": 55, 576 "execution_count": 17,
789 "id": "ecd03ee2-3523-40bd-afd1-4263a777bae0", 577 "id": "ecd03ee2-3523-40bd-afd1-4263a777bae0",
790 "metadata": {}, 578 "metadata": {},
791 "outputs": [], 579 "outputs": [],
@@ -837,7 +625,7 @@
837 }, 625 },
838 { 626 {
839 "cell_type": "code", 627 "cell_type": "code",
840 "execution_count": 56, 628 "execution_count": 18,
841 "id": "c67ca162-e8eb-4b4d-8c3c-246b000c5c13", 629 "id": "c67ca162-e8eb-4b4d-8c3c-246b000c5c13",
842 "metadata": {}, 630 "metadata": {},
843 "outputs": [ 631 "outputs": [
@@ -955,7 +743,7 @@
955 }, 743 },
956 { 744 {
957 "cell_type": "code", 745 "cell_type": "code",
958 "execution_count": 57, 746 "execution_count": 19,
959 "id": "edf9cfa7-d76c-428b-a39f-8c0697789031", 747 "id": "edf9cfa7-d76c-428b-a39f-8c0697789031",
960 "metadata": {}, 748 "metadata": {},
961 "outputs": [], 749 "outputs": [],
@@ -1005,7 +793,7 @@
1005 }, 793 },
1006 { 794 {
1007 "cell_type": "code", 795 "cell_type": "code",
1008 "execution_count": 58, 796 "execution_count": 20,
1009 "id": "ea583c17-c938-495a-9586-2027c66328a2", 797 "id": "ea583c17-c938-495a-9586-2027c66328a2",
1010 "metadata": {}, 798 "metadata": {},
1011 "outputs": [ 799 "outputs": [
@@ -1064,7 +852,7 @@
1064 }, 852 },
1065 { 853 {
1066 "cell_type": "code", 854 "cell_type": "code",
1067 "execution_count": 59, 855 "execution_count": 21,
1068 "id": "49d7f6e1-1f54-4b96-8203-5eae95f47ebe", 856 "id": "49d7f6e1-1f54-4b96-8203-5eae95f47ebe",
1069 "metadata": {}, 857 "metadata": {},
1070 "outputs": [ 858 "outputs": [
@@ -1167,10 +955,22 @@
1167 }, 955 },
1168 { 956 {
1169 "cell_type": "code", 957 "cell_type": "code",
1170 "execution_count": 60, 958 "execution_count": 22,
1171 "id": "4346260d-76af-437e-9c10-1c1d0c478695", 959 "id": "4346260d-76af-437e-9c10-1c1d0c478695",
1172 "metadata": {}, 960 "metadata": {},
1173 "outputs": [], 961 "outputs": [
962 {
963 "ename": "NameError",
964 "evalue": "name 'is_admin' is not defined",
965 "output_type": "error",
966 "traceback": [
967 "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
968 "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
969 "Cell \u001b[0;32mIn[22], line 25\u001b[0m\n\u001b[1;32m 19\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m decorated\n\u001b[1;32m 21\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m api_access_decorator\n\u001b[1;32m 24\u001b[0m \u001b[38;5;129m@requires_access\u001b[39m(access_secret\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mb28cfeaa65b73cf\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m---> 25\u001b[0m \u001b[38;5;129m@is_admin\u001b[39m\n\u001b[1;32m 26\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21msensitive_function\u001b[39m(data, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m 27\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"very sensitive function\"\"\"\u001b[39;00m\n\u001b[1;32m 28\u001b[0m db\u001b[38;5;241m.\u001b[39msave(data)\n",
970 "\u001b[0;31mNameError\u001b[0m: name 'is_admin' is not defined"
971 ]
972 }
973 ],
1174 "source": [ 974 "source": [
1175 "# Decorators (cont ...) - a complete example\n", 975 "# Decorators (cont ...) - a complete example\n",
1176 "\n", 976 "\n",
@@ -1253,7 +1053,7 @@
1253 "name": "python", 1053 "name": "python",
1254 "nbconvert_exporter": "python", 1054 "nbconvert_exporter": "python",
1255 "pygments_lexer": "ipython3", 1055 "pygments_lexer": "ipython3",
1256 "version": "3.11.1" 1056 "version": "3.11.5"
1257 } 1057 }
1258 }, 1058 },
1259 "nbformat": 4, 1059 "nbformat": 4,