From 0c715c889698e0ccc23deda777a0c4b077091fa7 Mon Sep 17 00:00:00 2001 From: timofey Date: Fri, 11 Nov 2022 14:55:00 +0000 Subject: [PATCH] introduction --- main.ipynb | 108 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 91 insertions(+), 17 deletions(-) diff --git a/main.ipynb b/main.ipynb index c86c563..eeb60fb 100644 --- a/main.ipynb +++ b/main.ipynb @@ -36,6 +36,38 @@ "* https://wiki.python.org/moin/FrontPage at the moment of writing, haven't read much of it" ] }, + { + "cell_type": "markdown", + "id": "05a28df4-45f8-4004-9e47-1a8132378499", + "metadata": { + "jp-MarkdownHeadingCollapsed": true, + "tags": [] + }, + "source": [ + "# Introduction\n", + "This notebook mostly features topics that are (IMO) overlooked.\n", + "* environment; there are a lot of choices for where to develop and where to deploy; I'll try to gather and classify as much viable options as I can.\n", + "* typing; not everyone knows about annotations' existence (let alone that of the module); typing greatly enhances programmer's performance in any PL, and python is not an exception to that.\n", + "* data model; python has a very strict and simple data model behind it; once you understand it, things like \"why this attribute returns a totally different thing\" will be more obvious.\n", + "* working with files; there are approaches beyond `open`+`.write`/`.read`.\n", + "* asyncio; the only correct way to do IO, if you don't wish to waste time and memory.\n", + "* obscure new features; `match`, `Self`, `type | type`, etc.; they are important, but not omnipresent as per their (in-language) novelty.\n", + "* styling;\n", + "\n", + "Most sections will eventually include \"prerequisites\" part (things you need to know before looking into this section); things required are mostly found in the official tutorial." + ] + }, + { + "cell_type": "markdown", + "id": "32ac085e-703e-41c9-99dc-e6bd7ce0d0ec", + "metadata": { + "jp-MarkdownHeadingCollapsed": true, + "tags": [] + }, + "source": [ + "# Environment" + ] + }, { "cell_type": "markdown", "id": "07390193-fdde-4bee-aec4-f5b3227dea06", @@ -44,12 +76,16 @@ }, "source": [ "# typing\n", - "Even a dynamically typed language can sometimes, at least, declare types. Python has built-in support for that via annotations." + "Even a dynamically typed language can sometimes, at least, declare types. Python has built-in support for that via annotations.\n", + "\n", + "***prerequisites:** functions*\n", + "\n", + "***also mentioned here:** `match`*" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "id": "5477e321-dc9a-4c9a-a4b6-a2549c0c0d37", "metadata": {}, "outputs": [], @@ -61,7 +97,6 @@ "cell_type": "markdown", "id": "990298fd-f154-45c7-b9a7-af63ae6e7c4e", "metadata": { - "jp-MarkdownHeadingCollapsed": true, "tags": [] }, "source": [ @@ -100,7 +135,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 5, "id": "0a72a4e0-0e01-498f-b770-e48116d5a97b", "metadata": {}, "outputs": [], @@ -124,7 +159,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 6, "id": "267accf3-6ab5-421a-a349-04d21669e586", "metadata": {}, "outputs": [], @@ -143,7 +178,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 7, "id": "eef4b91f-9a86-4d40-a049-d54f6a6f230f", "metadata": {}, "outputs": [], @@ -157,7 +192,10 @@ { "cell_type": "markdown", "id": "82158316-a752-4bcf-bd6f-c4cde017096b", - "metadata": {}, + "metadata": { + "jp-MarkdownHeadingCollapsed": true, + "tags": [] + }, "source": [ "### example with match\n", "though annotations don't usually influence anything during runtime, they make programming easier" @@ -165,7 +203,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 8, "id": "de6fd23d-1a81-47cc-ba84-b2f97ebe2cb3", "metadata": {}, "outputs": [ @@ -175,7 +213,7 @@ "('12', '12', None)" ] }, - "execution_count": 10, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -198,28 +236,37 @@ "cell_type": "markdown", "id": "c726cf29-f81e-4e52-95f1-128057fe4d0a", "metadata": { + "jp-MarkdownHeadingCollapsed": true, "tags": [] }, "source": [ "# Data model\n", - "https://docs.python.org/3/reference/datamodel.html" + "https://docs.python.org/3/reference/datamodel.html\n", + "\n", + "***prerequisites:** classes*" ] }, { "cell_type": "markdown", "id": "5a56ce30-37b4-463f-a446-895198dc0db8", "metadata": { + "jp-MarkdownHeadingCollapsed": true, "tags": [] }, "source": [ "# Working with files\n", - "There are a lot of ways, and directly using `open`+`.write`/`.read` is probably not fit for you task." + "There are a lot of ways, and directly using `open`+`.write`/`.read` is probably not fit for you task.\n", + "\n", + "***prerequisites:** variables, strings*\n", + "\n", + "***also mentioned here:** `with`*" ] }, { "cell_type": "markdown", "id": "daec179e-49a7-441e-95b4-d1b5d2c489fb", "metadata": { + "jp-MarkdownHeadingCollapsed": true, "tags": [] }, "source": [ @@ -258,6 +305,7 @@ "cell_type": "markdown", "id": "4e39ce1a-3396-45c9-bcad-19784326c32e", "metadata": { + "jp-MarkdownHeadingCollapsed": true, "tags": [] }, "source": [ @@ -267,7 +315,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 10, "id": "c59f89f6-d222-4382-8459-dd72c00f746e", "metadata": {}, "outputs": [ @@ -300,17 +348,22 @@ "cell_type": "markdown", "id": "6519c846-90fd-4828-9861-3cac9954880f", "metadata": { + "jp-MarkdownHeadingCollapsed": true, "tags": [] }, "source": [ "# asyncio\n", "If you do anything with IO, you should probably do it **asynchronously** \n", - "https://docs.python.org/3/library/asyncio.html" + "https://docs.python.org/3/library/asyncio.html\n", + "\n", + "***prerequisites:** functions*\n", + "\n", + "***also mentioned here:** `with`*" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 11, "id": "ffc18b3f-f63a-4556-bc24-d3a7d69756ac", "metadata": {}, "outputs": [], @@ -322,6 +375,7 @@ "cell_type": "markdown", "id": "c0fe1271-d784-4c45-9294-795a6b01b785", "metadata": { + "jp-MarkdownHeadingCollapsed": true, "tags": [] }, "source": [ @@ -340,6 +394,7 @@ "cell_type": "markdown", "id": "f06ca023-f840-4488-b9b2-cfd302193858", "metadata": { + "jp-MarkdownHeadingCollapsed": true, "tags": [] }, "source": [ @@ -353,6 +408,7 @@ "cell_type": "markdown", "id": "d46018f9-8609-4408-ab97-48dbea0bfd7c", "metadata": { + "jp-MarkdownHeadingCollapsed": true, "tags": [] }, "source": [ @@ -365,6 +421,7 @@ "cell_type": "markdown", "id": "5205f839-7b22-4144-9e7c-29093b05e2ca", "metadata": { + "jp-MarkdownHeadingCollapsed": true, "tags": [] }, "source": [ @@ -379,7 +436,10 @@ { "cell_type": "markdown", "id": "f9cf426c-94fa-4907-b182-a759d0934080", - "metadata": {}, + "metadata": { + "jp-MarkdownHeadingCollapsed": true, + "tags": [] + }, "source": [ "### `async with` -- asynchronous context management\n", "Same as `with`, but `async def __aenter__`/`async def __aexit__` instead of `def __enter__`/`def __exit__`." @@ -388,11 +448,25 @@ { "cell_type": "markdown", "id": "21f08324-0b14-4b35-bc6e-7a7329520ed9", - "metadata": {}, + "metadata": { + "jp-MarkdownHeadingCollapsed": true, + "tags": [] + }, "source": [ "## Level 1: using high-level APIs" ] }, + { + "cell_type": "markdown", + "id": "3f4e5b5e-d851-4a9b-a17d-c9a387f277fb", + "metadata": { + "jp-MarkdownHeadingCollapsed": true, + "tags": [] + }, + "source": [ + "## Level 2: using low-level APIs" + ] + }, { "cell_type": "markdown", "id": "fe6dcf16-522a-4b20-99b6-54b92d59e19e", @@ -401,7 +475,7 @@ "tags": [] }, "source": [ - "# Last section, so the empty cell does not get stuck with previous sections" + "# Last section, for the empty cell(s) to not get stuck with previous sections" ] }, {