From 24d5938dfb98cc5c27eaec51b1da06b2f4a66932 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Sun, 17 Sep 2023 01:22:00 +0200 Subject: Update notebooks/python/python_oo.ipynb and notebooks/sqlalchemy/sqlalchemy.ipynb --- notebooks/python/python_3_8_to_3_11.ipynb | 2 +- notebooks/python/python_intro.ipynb | 260 ++++-------------------------- notebooks/python/python_oo.ipynb | 18 +-- 3 files changed, 40 insertions(+), 240 deletions(-) (limited to 'notebooks/python') diff --git a/notebooks/python/python_3_8_to_3_11.ipynb b/notebooks/python/python_3_8_to_3_11.ipynb index 1b0467c..e2a08e9 100644 --- a/notebooks/python/python_3_8_to_3_11.ipynb +++ b/notebooks/python/python_3_8_to_3_11.ipynb @@ -834,7 +834,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.8" + "version": "3.11.4" } }, "nbformat": 4, 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 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 12, "id": "54c9e132-30b0-41bf-97e9-0e8b94f3d202", "metadata": {}, "outputs": [], @@ -109,7 +109,7 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 13, "id": "bd6134d9-cc0e-4b45-b6b3-50210f6395e2", "metadata": {}, "outputs": [], @@ -140,7 +140,7 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 14, "id": "cd2b7f98-ea16-49e2-9d19-f37266bd4f3a", "metadata": {}, "outputs": [ @@ -148,136 +148,20 @@ "name": "stdout", "output_type": "stream", "text": [ - "'can be written like this'\n" - ] - }, - { - "data": { - "text/plain": [ - "'foo bar'" - ] - }, - "execution_count": 52, - "metadata": {}, - "output_type": "execute_result" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ + "'can be written like this'\n", "works just fine\n", "works\n", "just\n", "fine\n" ] }, - { - "data": { - "text/plain": [ - "'S'" - ] - }, - "execution_count": 52, - "metadata": {}, - "output_type": "execute_result" - }, - { - "data": { - "text/plain": [ - "'t'" - ] - }, - "execution_count": 52, - "metadata": {}, - "output_type": "execute_result" - }, - { - "data": { - "text/plain": [ - "'tatnett'" - ] - }, - "execution_count": 52, - "metadata": {}, - "output_type": "execute_result" - }, - { - "data": { - "text/plain": [ - "'tatnet'" - ] - }, - "execution_count": 52, - "metadata": {}, - "output_type": "execute_result" - }, - { - "data": { - "text/plain": [ - "'ett'" - ] - }, - "execution_count": 52, - "metadata": {}, - "output_type": "execute_result" - }, - { - "data": { - "text/plain": [ - "'tte'" - ] - }, - "execution_count": 52, - "metadata": {}, - "output_type": "execute_result" - }, - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 52, - "metadata": {}, - "output_type": "execute_result" - }, - { - "data": { - "text/plain": [ - "False" - ] - }, - "execution_count": 52, - "metadata": {}, - "output_type": "execute_result" - }, - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 52, - "metadata": {}, - "output_type": "execute_result" - }, - { - "data": { - "text/plain": [ - "b'B\\xc3\\x98!'" - ] - }, - "execution_count": 52, - "metadata": {}, - "output_type": "execute_result" - }, { "data": { "text/plain": [ "'BØ!'" ] }, - "execution_count": 52, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -520,87 +404,17 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 15, "id": "f4a4ea99-4038-4b61-9b8d-9ce623e6a663", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "35082617072" - ] - }, - "execution_count": 53, - "metadata": {}, - "output_type": "execute_result" - }, - { - "data": { - "text/plain": [ - "35082617104" + "-42990858669078524" ] }, - "execution_count": 53, - "metadata": {}, - "output_type": "execute_result" - }, - { - "data": { - "text/plain": [ - "'H'" - ] - }, - "execution_count": 53, - "metadata": {}, - "output_type": "execute_result" - }, - { - "data": { - "text/plain": [ - "-6333845781340707986" - ] - }, - "execution_count": 53, - "metadata": {}, - "output_type": "execute_result" - }, - { - "data": { - "text/plain": [ - "36350585520" - ] - }, - "execution_count": 53, - "metadata": {}, - "output_type": "execute_result" - }, - { - "data": { - "text/plain": [ - "36350587520" - ] - }, - "execution_count": 53, - "metadata": {}, - "output_type": "execute_result" - }, - { - "data": { - "text/plain": [ - "8927089887582119463" - ] - }, - "execution_count": 53, - "metadata": {}, - "output_type": "execute_result" - }, - { - "data": { - "text/plain": [ - "8927089887582119463" - ] - }, - "execution_count": 53, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -703,41 +517,15 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 16, "id": "bf95f44a-1257-440f-b35f-a8536c8c4363", "metadata": {}, "outputs": [ - { - "data": { - "text/plain": [ - "7" - ] - }, - "execution_count": 54, - "metadata": {}, - "output_type": "execute_result" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "9\n" - ] - }, - { - "data": { - "text/plain": [ - "[9, -2]" - ] - }, - "execution_count": 54, - "metadata": {}, - "output_type": "execute_result" - }, { "name": "stdout", "output_type": "stream", "text": [ + "9\n", "[9, 5]\n" ] } @@ -785,7 +573,7 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 17, "id": "ecd03ee2-3523-40bd-afd1-4263a777bae0", "metadata": {}, "outputs": [], @@ -837,7 +625,7 @@ }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 18, "id": "c67ca162-e8eb-4b4d-8c3c-246b000c5c13", "metadata": {}, "outputs": [ @@ -955,7 +743,7 @@ }, { "cell_type": "code", - "execution_count": 57, + "execution_count": 19, "id": "edf9cfa7-d76c-428b-a39f-8c0697789031", "metadata": {}, "outputs": [], @@ -1005,7 +793,7 @@ }, { "cell_type": "code", - "execution_count": 58, + "execution_count": 20, "id": "ea583c17-c938-495a-9586-2027c66328a2", "metadata": {}, "outputs": [ @@ -1064,7 +852,7 @@ }, { "cell_type": "code", - "execution_count": 59, + "execution_count": 21, "id": "49d7f6e1-1f54-4b96-8203-5eae95f47ebe", "metadata": {}, "outputs": [ @@ -1167,10 +955,22 @@ }, { "cell_type": "code", - "execution_count": 60, + "execution_count": 22, "id": "4346260d-76af-437e-9c10-1c1d0c478695", "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'is_admin' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "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", + "\u001b[0;31mNameError\u001b[0m: name 'is_admin' is not defined" + ] + } + ], "source": [ "# Decorators (cont ...) - a complete example\n", "\n", @@ -1253,7 +1053,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.1" + "version": "3.11.5" } }, "nbformat": 4, diff --git a/notebooks/python/python_oo.ipynb b/notebooks/python/python_oo.ipynb index 1c655d0..0ab369b 100644 --- a/notebooks/python/python_oo.ipynb +++ b/notebooks/python/python_oo.ipynb @@ -226,17 +226,17 @@ "name": "stdout", "output_type": "stream", "text": [ - "car1.get_obj_info_str() = \"I am <__main__.Car object at 0x7fc7add96f10> with id 140495591927568 from with id 94628241379728\"\n", - "car2.get_obj_info_str() = \"I am <__main__.Car object at 0x7fc7aef459d0> with id 140495610468816 from with id 94628241379728\"\n", - "car1.model = 'BMW', car1.reg_nr = 'EC76183', car1.extras = ['GPSnav', 'Sound system'], id(car1.cls_extras) = 140495591909184, id(car1.get_obj_info_str) = 140495591927808\n", - "car2.model = 'Scoda', car2.reg_nr = 'BD77655', car2.extras = ['GPSnav'], id(car2.cls_extras) = 140495591909184, id(car2.get_obj_info_str) = 140495591927936\n", - "id(Car.cls_extras) = 140495591909184, id(Car.get_obj_info_str) = 140495591682944\n", - "car1.cls_extras = ['GPSnav', 'Sound system'], id(car1.cls_extras) = 140495591909184\n", - "car2.cls_extras = ['GPSnav', 'Sound system'], id(car2.cls_extras) = 140495591909184\n", + "car1.get_obj_info_str() = \"I am <__main__.Car object at 0x7f70e643d590> with id 140122876269968 from with id 93964809433504\"\n", + "car2.get_obj_info_str() = \"I am <__main__.Car object at 0x7f70e63ddf10> with id 140122875879184 from with id 93964809433504\"\n", + "car1.model = 'BMW', car1.reg_nr = 'EC76183', car1.extras = ['GPSnav', 'Sound system'], id(car1.cls_extras) = 140122875882432, id(car1.get_obj_info_str) = 140122875878080\n", + "car2.model = 'Scoda', car2.reg_nr = 'BD77655', car2.extras = ['GPSnav'], id(car2.cls_extras) = 140122875882432, id(car2.get_obj_info_str) = 140122875880192\n", + "id(Car.cls_extras) = 140122875882432, id(Car.get_obj_info_str) = 140122875964416\n", + "car1.cls_extras = ['GPSnav', 'Sound system'], id(car1.cls_extras) = 140122875882432\n", + "car2.cls_extras = ['GPSnav', 'Sound system'], id(car2.cls_extras) = 140122875882432\n", "True\n", "hasattr(car1, 'import_tax_paid') = True\n", "hasattr(car2, 'import_tax_paid') = False\n", - "id(car1.__class__) = 94628241379728, id(car2.__class__) = 94628241379728, id(Car) = 94628241379728\n" + "id(car1.__class__) = 93964809433504, id(car2.__class__) = 93964809433504, id(Car) = 93964809433504\n" ] } ], @@ -1418,7 +1418,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.1" + "version": "3.11.3" } }, "nbformat": 4, -- cgit v1.3