From 6a6d09c488826c5d8e618f3d0a5db9997914b5f5 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Tue, 6 Dec 2022 05:50:53 +0100 Subject: Update python/python_3_8_to_3_11.ipynb, python/python_intro.ipynb, python/python_oo.ipynb and sqlalchemy/sqlalchemy.ipynb --- notebooks/python/python_oo.ipynb | 77 +++++++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 17 deletions(-) (limited to 'notebooks/python/python_oo.ipynb') diff --git a/notebooks/python/python_oo.ipynb b/notebooks/python/python_oo.ipynb index fe717a9..7147a87 100644 --- a/notebooks/python/python_oo.ipynb +++ b/notebooks/python/python_oo.ipynb @@ -106,7 +106,7 @@ "\n", "- class variable - attribute of which a single copy exists, regardless of how many instances of the class exist\n", "\n", - "- object / instance variable - attribute for which each instantiated object of the class has a separate copy, or instance\n", + "- object / instance variable, object / instance attribute - attribute for which each instantiated object of the class has a separate copy, or instance\n", "\n", "- method - member function - function that is an attribute" ] @@ -208,7 +208,7 @@ }, { "cell_type": "code", - "execution_count": 70, + "execution_count": 1, "id": "391e816e-c53b-454b-9e9f-3587234f1fea", "metadata": {}, "outputs": [ @@ -241,6 +241,8 @@ " initialization of the base class part of the instance;\n", " for example: super().__init__([args...]).\n", " \"\"\"\n", + " # defines instance attributes that will \"live\" as long as\n", + " # the object / instance \"lives\" \n", " self._x = x # _ indicates \"protected\" attribute\n", " self.__y = y # not a typo: __ indicates \"private\" attribute.\n", "\n", @@ -306,7 +308,7 @@ }, { "cell_type": "code", - "execution_count": 71, + "execution_count": 2, "id": "e82feefb-025d-4cbb-a8ac-ddc3cc01269c", "metadata": {}, "outputs": [ @@ -389,7 +391,7 @@ }, { "cell_type": "code", - "execution_count": 72, + "execution_count": 3, "id": "71a90ec6-3cc0-441e-a866-c2c2b9984559", "metadata": {}, "outputs": [ @@ -503,7 +505,7 @@ }, { "cell_type": "code", - "execution_count": 73, + "execution_count": 4, "id": "a4d2735d-d167-4f43-ad55-cb3d13ece2dc", "metadata": {}, "outputs": [ @@ -546,7 +548,7 @@ }, { "cell_type": "code", - "execution_count": 74, + "execution_count": 5, "id": "a6ead5e6-e987-4bda-bf48-30f91877278d", "metadata": {}, "outputs": [ @@ -605,7 +607,7 @@ }, { "cell_type": "code", - "execution_count": 75, + "execution_count": 6, "id": "11f6a3fb-64d7-40a9-a130-27548ec4b802", "metadata": {}, "outputs": [ @@ -683,7 +685,7 @@ }, { "cell_type": "code", - "execution_count": 76, + "execution_count": 7, "id": "c345a69f-02da-40e7-bb37-c0511b6af096", "metadata": {}, "outputs": [ @@ -774,7 +776,7 @@ }, { "cell_type": "code", - "execution_count": 77, + "execution_count": 8, "id": "44d47e1c-1a06-4577-8db6-6ec78ce5cef8", "metadata": {}, "outputs": [ @@ -948,7 +950,7 @@ }, { "cell_type": "code", - "execution_count": 78, + "execution_count": 9, "id": "e6076925-75f0-456c-aed5-7db0a24a67a1", "metadata": {}, "outputs": [ @@ -1059,7 +1061,7 @@ }, { "cell_type": "code", - "execution_count": 79, + "execution_count": 13, "id": "cf79617a-95d2-48f2-be66-fa1fa34e4e04", "metadata": {}, "outputs": [ @@ -1067,7 +1069,30 @@ "name": "stdout", "output_type": "stream", "text": [ - "Simeon's MRO: (, , , , , , , , , )\n" + "Simeon's MRO: (, , , , , , , , , )\n", + "Help on Simeon in module __main__ object:\n", + "\n", + "class Simeon(Mother, Father)\n", + " | Method resolution order:\n", + " | Simeon\n", + " | Mother\n", + " | Grandmother1\n", + " | Grandfather1\n", + " | Father\n", + " | Grandmother2\n", + " | Grandfather2\n", + " | Adam\n", + " | Eve\n", + " | builtins.object\n", + " | \n", + " | Data descriptors inherited from Adam:\n", + " | \n", + " | __dict__\n", + " | dictionary for instance variables (if defined)\n", + " | \n", + " | __weakref__\n", + " | list of weak references to the object (if defined)\n", + "\n" ] } ], @@ -1108,12 +1133,14 @@ " pass\n", "\n", "\n", - "print(f\"Simeon's MRO: {Simeon.__mro__}\")" + "print(f\"Simeon's MRO: {Simeon.__mro__}\")\n", + "simeon = Simeon()\n", + "help(simeon)" ] }, { "cell_type": "code", - "execution_count": 80, + "execution_count": 11, "id": "95a1d0cc-0006-4ddc-b08d-d0b8b02acfba", "metadata": {}, "outputs": [ @@ -1179,7 +1206,7 @@ }, { "cell_type": "code", - "execution_count": 81, + "execution_count": 12, "id": "38066107-0190-4383-ba14-a4e9cd454a9c", "metadata": {}, "outputs": [ @@ -1189,7 +1216,23 @@ "text": [ "Using mock data\n", "Extracting production plans from data\n", - "some magic is happening here...\n", + "some magic is happening here...\n" + ] + }, + { + "data": { + "text/plain": [ + "'{}'" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ "(, , , , )\n" ] } @@ -1248,7 +1291,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.0" + "version": "3.10.8" } }, "nbformat": 4, -- cgit v1.3