{"id":458247,"date":"2025-04-30T21:00:21","date_gmt":"2025-04-30T21:00:21","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=458247"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=458247","title":{"rendered":"<span>14 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0444\u0438\u0447 Python (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c pythonic)<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/companies\/ruvds\/articles\/905832\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/zf\/7s\/e0\/zf7se0iyc_f_541nybtbdqayspu.jpeg\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/zf\/7s\/e0\/zf7se0iyc_f_541nybtbdqayspu.jpeg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/zf\/7s\/e0\/zf7se0iyc_f_541nybtbdqayspu.jpeg 781w\" loading=\"lazy\" decode=\"async\"\/><\/div>\n<p><\/a><br \/> Python \u2014 \u043e\u0434\u0438\u043d \u0438\u0437 <a href=\"https:\/\/survey.stackoverflow.co\/2024\/technology#most-popular-technologies\">\u0441\u0430\u043c\u044b\u0445 \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/a> \u0432 \u043c\u0438\u0440\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u0438\u0437-\u0437\u0430 \u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0435\u0439 \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c <i>\u0447\u0442\u043e-\u0442\u043e<\/i>, \u043e\u043d \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0442\u0430\u043a\u0436\u0435 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043d\u0435\u0434\u043e\u043e\u0446\u0435\u043d\u0451\u043d\u043d\u044b\u0445.<\/p>\n<p> \u0415\u0441\u043b\u0438 \u0437\u0430\u0433\u0443\u0433\u043b\u0438\u0442\u044c <a href=\"https:\/\/www.google.com\/search?q=Top+10+Advanced+Python+Tricks\"><code>\u043b\u0443\u0447\u0448\u0438\u0435 10 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0445 \u0445\u0438\u0442\u0440\u043e\u0441\u0442\u0435\u0439 Python<\/code><\/a>, \u0442\u043e \u0432\u044b \u043d\u0430\u0439\u0434\u0451\u0442\u0435 \u043a\u0443\u0447\u0443 \u043f\u043e\u0441\u0442\u043e\u0432 \u0438\u043b\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u043d\u0430 LinkedIn \u0441 \u043e\u0431\u0437\u043e\u0440\u043e\u043c \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0445 (\u043d\u043e \u0432\u0441\u0451 \u0436\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445) \u0432\u0435\u0449\u0435\u0439 \u0442\u0438\u043f\u0430 <code>\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432<\/code> \u0438\u043b\u0438 <code>\u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439<\/code>.<\/p>\n<p> \u042f \u043f\u0438\u0448\u0443 \u043d\u0430 Python \u0443\u0436\u0435 \u0434\u0432\u0435\u043d\u0430\u0434\u0446\u0430\u0442\u044c \u043b\u0435\u0442, \u0438 \u0437\u0430 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0448\u0451\u043b \u043a\u0443\u0447\u0443 \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445, \u043d\u0435\u0434\u043e\u043e\u0446\u0435\u043d\u0451\u043d\u043d\u044b\u0445, \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0438\u043b\u0438 (\u043a\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u043a\u0442\u043e-\u0442\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c) \u00ab\u043d\u0435-pythonic\u00bb \u0445\u0438\u0442\u0440\u043e\u0441\u0442\u0435\u0439, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 <b><font color=\"#3AC1EF\">\u043f\u043e-\u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443<\/font><\/b> \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0433\u043e \u0434\u043b\u044f Python.<\/p>\n<p> \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437 14 \u043b\u0443\u0447\u0448\u0438\u0445 \u0442\u0430\u043a\u0438\u0445 \u0444\u0438\u0447 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0438\u0445 \u0433\u043b\u0443\u0431\u0436\u0435.<a name=\"habracut\"><\/a><\/p>\n<h2><font color=\"#3AC1EF\">1. \u041f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438<\/font><\/h2>\n<p> <strong><code>@overload<\/code><\/strong> \u2014 \u044d\u0442\u043e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f <code>typing<\/code> Python, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041a\u0430\u0436\u0434\u0430\u044f \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043c\u043e\u0434\u0443\u043b\u044e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0442\u0438\u043f\u043e\u0432, \u043a\u0430\u043a\u0438\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b.<\/p>\n<p> \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 <code>mode=split<\/code>, \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043c\u043e\u0436\u0435\u0442 <em>\u0442\u043e\u043b\u044c\u043a\u043e<\/em> <code>list[str]<\/code>, \u0430 \u0435\u0441\u043b\u0438 <code>mode=upper<\/code>, \u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f <em>\u0442\u043e\u043b\u044c\u043a\u043e<\/em> <code>str<\/code>. (\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0442\u0438\u043f <code>Literal<\/code> \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f mode \u0438\u043b\u0438 <code>split<\/code>, \u0438\u043b\u0438 <code>upper<\/code>.)<\/p>\n<pre><code class=\"python\">from typing import Literal, overload  @overload def transform(data: str, mode: Literal[\"split\"]) -&gt; list[str]:     ...  @overload def transform(data: str, mode: Literal[\"upper\"]) -&gt; str:     ...  def transform(data: str, mode: Literal[\"split\", \"upper\"]) -&gt; list[str] | str:     if mode == \"split\":         return data.split()     else:         return data.upper()  split_words = transform(\"hello world\", \"split\")  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0442\u0438\u043f list[str] split_words[0]  # \u041c\u043e\u0434\u0443\u043b\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u0438\u043f\u043e\u0432 \u0434\u043e\u0432\u043e\u043b\u0435\u043d  upper_words = transform(\"hello world\", \"upper\")  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0442\u0438\u043f str upper_words.lower()  # \u041c\u043e\u0434\u0443\u043b\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u0438\u043f\u043e\u0432 \u0434\u043e\u0432\u043e\u043b\u0435\u043d  upper_words.append(\"!\")  # \u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0443 \"append\" \u0434\u043b\u044f \"str\"<\/code><\/pre>\n<p> \u041f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0433\u0443\u0442 \u043c\u0435\u043d\u044f\u0442\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0442\u0438\u043f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043d\u043e \u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0435\u0435! \u0412 \u0435\u0449\u0451 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u043b\u0441\u044f \u0418\u041b\u0418 <code>id<\/code>, \u0418\u041b\u0418 <code>username<\/code>, \u043d\u043e <em><b><font color=\"#3AC1EF\">\u043d\u0435 \u043e\u0431\u0430<\/font><\/b><\/em>.<\/p>\n<pre><code class=\"python\">@overload def get_user(id: int = ..., username: None = None) -&gt; User:     ...  @overload def get_user(id: None = None, username: str = ...) -&gt; User:     ...  def get_user(id: int | None = None, username: str | None = None) -&gt; User:     ...  get_user(id=1)  # \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442! get_user(username=\"John\")  # \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442! get_user(id=1, username=\"John\")  # \u041d\u0438 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043e\u043a \"get_user\" \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c<\/code><\/pre>\n<p> <\/p>\n<blockquote><p><code>...<\/code> \u2014 \u044d\u0442\u043e \u043e\u0441\u043e\u0431\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0435 \u0432 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430\u0445, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439, \u043d\u043e \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p><\/blockquote>\n<p> <b><font color=\"#3AC1EF\">\u0411\u043e\u043d\u0443\u0441\u043d\u0430\u044f \u0445\u0438\u0442\u0440\u043e\u0441\u0442\u044c:<\/font><\/b> \u043a\u0430\u043a \u0432\u044b, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0437\u043d\u0430\u0435\u0442\u0435, Python \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 <b><font color=\"#3AC1EF\">\u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044b<\/font><\/b>. \u041e\u043d\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0443 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a, \u0447\u0442\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0435\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0442\u0438\u043f\u043e\u0432. \u041c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0438\u0445, \u043a\u0430\u043a \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u0443\u044e \u0440\u0430\u0437\u043d\u043e\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u044c Enum!<\/p>\n<pre><code class=\"python\">def set_color(color: Literal[\"red\", \"blue\", \"green\"]) -&gt; None:     ...  set_color(\"red\") set_color(\"blue\") set_color(\"green\") set_color(\"fuchsia\")  # \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0442\u0438\u043f\u0430 \"Literal['fuchsia']\" \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0443 \"color\"<\/code><\/pre>\n<p> <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b<\/font><\/h3>\n<p> <\/p>\n<ul>\n<li><a href=\"https:\/\/adamj.eu\/tech\/2021\/05\/29\/python-type-hints-how-to-use-overload\/\">Python Type Hints: How to use @overload<\/a><\/li>\n<li><a href=\"https:\/\/peps.python.org\/pep-3124\/\">PEP 3124 \u2014 Overloading, Generic Functions, Interfaces, and Adaptation<\/a><\/li>\n<li><a href=\"https:\/\/docs.python.org\/3\/library\/typing.html#overload\">Python Docs \u2014 Overloads<\/a><\/li>\n<li><a href=\"https:\/\/peps.python.org\/pep-0586\/\">PEP 586 \u2014 Literal Types<\/a><\/li>\n<\/ul>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">2. \u0422\u043e\u043b\u044c\u043a\u043e \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b<\/font><\/h2>\n<p> \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435, \u0438 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0442\u044c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c \u0438 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445, \u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u041d\u043e \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u043e? \u042d\u0442\u0438\u043c \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c <b><font color=\"#3AC1EF\">\u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b<\/font><\/b>.<\/p>\n<pre><code class=\"python\">def foo(a, b, \/, c, d, *, e, f): #         ^        ^ # \u0412\u0438\u0434\u0435\u043b\u0438 \u0442\u0430\u043a\u043e\u0435 \u0440\u0430\u043d\u044c\u0448\u0435? ...<\/code><\/pre>\n<p> <b><code>*<\/code><\/b> \u043e\u0442\u043c\u0435\u0447\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438. \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u043e\u0441\u043b\u0435 * \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b.<\/p>\n<pre><code class=\"python\">#   KW+POS | KW ONLY #       vv | vv def foo(a, *, b):     ...  # == \u0420\u0410\u0417\u0420\u0415\u0428\u0415\u041d\u041e == foo(a=1, b=2)  # \u0412\u0441\u0435 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 foo(1, b=2)  # \u041f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0445, \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445  # == \u0417\u0410\u041f\u0420\u0415\u0429\u0415\u041d\u041e == foo(1, 2)  # \u041d\u0435\u043b\u044c\u0437\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432\u043c\u0435\u0441\u0442\u043e \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e #      ^<\/code><\/pre>\n<p> <strong><code>\/<\/code><\/strong> \u043e\u0442\u043c\u0435\u0447\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438. \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b <em>\u043f\u0435\u0440\u0435\u0434<\/em> <code>\/<\/code> <em>\u0434\u043e\u043b\u0436\u043d\u044b<\/em> \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u043e \u0438 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435.<\/p>\n<pre><code class=\"python\"># POS ONLY | KW POS #       vv | vv def bar(a, \/, b):     ...  # == \u0420\u0410\u0417\u0420\u0415\u0428\u0415\u041d\u041e == bar(1, 2)  # \u0412\u0441\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0435 bar(1, b=2)  # \u041f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0445, \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445  # == \u0417\u0410\u041f\u0420\u0415\u0429\u0415\u041d\u041e == bar(a=1, b=2)  # \u041d\u0435\u043b\u044c\u0437\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e #   ^<\/code><\/pre>\n<p> \u0422\u043e\u043b\u044c\u043a\u043e \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 API, \u043e\u043d\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b<\/font><\/h3>\n<p> <\/p>\n<ul>\n<li><a href=\"https:\/\/thepythoncodingbook.com\/2022\/12\/11\/positional-only-and-keyword-only-arguments-in-python\/\">Using Positional-Only And Keyword-Only Arguments in Python<\/a><\/li>\n<li><a href=\"https:\/\/stackoverflow.com\/questions\/58477827\/why-use-positional-only-parameters-in-python-3-8\">Stack Overflow: Why use positional-only parameters in Python 3.8+?<\/a><\/li>\n<li><a href=\"https:\/\/peps.python.org\/pep-3102\/\">PEP 3102 \u2013 Keyword-Only Arguments<\/a><\/li>\n<li><a href=\"https:\/\/peps.python.org\/pep-0570\/\">PEP 570 \u2013 Python Positional-Only Parameters<\/a><\/li>\n<\/ul>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">3. Future-\u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438<\/font><\/h2>\n<p> \u041a\u0440\u0430\u0442\u043a\u0438\u0439 \u0443\u0440\u043e\u043a \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 Python:<\/p>\n<blockquote><p>\u042d\u0442\u043e, \u0441\u043a\u043e\u0440\u0435\u0435, \u043d\u0435 \u0444\u0438\u0447\u0430 Python, \u0430 \u0443\u0440\u043e\u043a \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0442\u0438\u043f\u043e\u0432 Python \u0438 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 <code>from __future__ import annotations<\/code> \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u0441\u044f \u0432\u0430\u043c \u0432 \u043a\u043e\u0434\u0435 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0430.<\/p><\/blockquote>\n<p> <em>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u0438\u043f\u043e\u0432 Python \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c, \u043a\u0430\u043a \u0445\u0430\u043a<\/em>. \u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0431\u044b\u043b \u0432\u0432\u0435\u0434\u0451\u043d \u0432 <a href=\"https:\/\/peps.python.org\/pep-3107\/\">PEP 3107<\/a> Python 3.0 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0430\u043a \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043d\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0442\u0438\u043f\u043e\u0432.<\/p>\n<p> \u041d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440 \u0442\u0438\u043f\u043e\u0432 \u0431\u044b\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u043f\u043e\u0437\u0436\u0435, \u0432 Python 3.5 \u0441 <a href=\"https:\/\/peps.python.org\/pep-0484\/\">PEP 484<\/a>, \u043d\u043e \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f\/\u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0438. \u042d\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0432 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u043e \u0432\u0441\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0439 \u0431\u043e\u043b\u0438 \u0441 \u043e\u0434\u043d\u0438\u043c \u0442\u0438\u043f\u043e\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c: <b><font color=\"#3AC1EF\">\u043f\u0440\u044f\u043c\u044b\u043c\u0438 \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438<\/font><\/b>.<\/p>\n<p> \u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u044f\u043c\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0435\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f) \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u0438 \u043e\u0442\u043a\u0430\u0442\u0430 \u043a \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u0432, \u0441\u043d\u0438\u0436\u0430\u044f \u0438\u0437\u044f\u0449\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u0434\u0430 \u0438 \u043f\u043e\u0432\u044b\u0448\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u043a.<\/p>\n<pre><code class=\"python\"># \u042d\u0442\u043e \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 class Foo:     def action(self) -&gt; Foo:         # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0430\u044f \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 `-&gt; Foo` \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f,         # \u043d\u043e \u043a\u043b\u0430\u0441\u0441 `Foo` \u043d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0435\u0449\u0451 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d,         # \u0432\u044b\u0437\u044b\u0432\u0430\u044f NameError \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0442\u0438\u043f\u043e\u0432.         ...<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"python\"># \u042d\u0442\u043e \u043e\u0431\u0445\u043e\u0434\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 -&gt; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 class Bar:     def action(self) -&gt; \"Bar\":         # \u041e\u0431\u0445\u043e\u0434\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u043c\u0438 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u0430\u043c\u0438: \u043d\u0435\u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0438 \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u043a         ...<\/code><\/pre>\n<p> <a href=\"https:\/\/peps.python.org\/pep-0563\/\">PEP 563: Postponed Evaluation of Annotations<\/a> \u0431\u044b\u043b\u043e \u043d\u0430\u0446\u0435\u043b\u0435\u043d\u043e \u043d\u0430 \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440 \u0442\u0438\u043f\u043e\u0432. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f, PEP 563 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 \u0432 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f, \u043e\u0431\u044b\u0447\u043d\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430. \u042d\u0442\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0441\u0442\u044b\u0435 \u043f\u0440\u044f\u043c\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0431\u0435\u0437 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u0432 \u0432 \u044f\u0432\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u0438 \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u043e\u0432\u0435\u0440\u0445\u0435\u0434 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440 \u0442\u0438\u043f\u043e\u0432 \u0432 \u0441\u0440\u0435\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"python\">from __future__ import annotations  class Foo:     def bar(self) -&gt; Foo:  # \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!         ...<\/code><\/pre>\n<p> <b><font color=\"#3AC1EF\">\u0422\u0430\u043a \u0432 \u0447\u0451\u043c \u0436\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430?<\/font><\/b><br \/> \u0414\u043b\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0442\u0438\u043f\u043e\u0432 \u044d\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u043c\u0435\u0440\u0435 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u043c. \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 PEP 563 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0435\u0433\u043e, \u043f\u043e \u0441\u0443\u0442\u0438, \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435 \u043e\u0431\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438, \u043a\u0430\u043a \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438, \u0442\u043e \u0432\u0441\u0435, \u043a\u0442\u043e \u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u043c \u0442\u0438\u043f\u0430\u043c \u0432 \u0441\u0440\u0435\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, ORM, \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u044b, \u0438\u043d\u044a\u0435\u043a\u0442\u043e\u0440\u044b \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435) \u0431\u0443\u0434\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 \u0441 \u044d\u0442\u043e\u0439 \u043d\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439.<\/p>\n<p> \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0436\u0435 \u0441\u043f\u0443\u0441\u0442\u044f \u0434\u0435\u0441\u044f\u0442\u044c \u043b\u0435\u0442 \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f PEP \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 Python (3.13 \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043c\u043e\u0435\u0433\u043e \u043f\u043e\u0441\u0442\u0430) \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0442\u0443 \u0436\u0435 \u0445\u0430\u043a-\u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0442\u0438\u043f\u043e\u0432, \u0432\u043d\u0435\u0434\u0440\u0451\u043d\u043d\u0443\u044e \u0432 Python 3.5.<\/p>\n<pre><code class=\"python\"># ===== \u041e\u0431\u044b\u0447\u043d\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f Python ===== def foobar() -&gt; int:     return 1  ret_type = foobar.__annotations__.get(\"return\") ret_type # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442: &lt;class 'int'&gt; new_int = ret_type()<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"python\"># ===== \u0421 \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435\u043c ===== from __future__ import annotations  def foobar() -&gt; int:     return 1  ret_type = foobar.__annotations__.get(\"return\") ret_type # \"int\" (str) new_int = ret_type()  # TypeError: 'str' object is not callable<\/code><\/pre>\n<p> \u0412 \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0435\u043c\u0441\u044f <a href=\"https:\/\/peps.python.org\/pep-0649\/\">PEP 649<\/a> \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d \u043d\u043e\u0432\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 Python \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e, \u0438\u043b\u0438 \u00ab\u043b\u0435\u043d\u0438\u0432\u043e\u0433\u043e\u00bb \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u043b\u043e\u0441\u044c \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e, \u044d\u0442\u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043d\u0438\u043c.<\/p>\n<p> \u042d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0435\u0439 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0445\u0440\u0430\u043d\u044f\u0449\u0443\u044e\u0441\u044f \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0435 <code>__annotate__<\/code>. \u041f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0443 <code>__annotations__<\/code> \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0438 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440, \u0434\u0435\u043b\u0430\u044f \u0438\u0445 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430.<\/p>\n<pre><code class=\"python\"># \u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u0438\u0437 PEP 649  class function:     # __annotations__ \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u2014 \u044d\u0442\u043e \u0443\u0436\u0435     # \"data descriptor\" \u0432 Python, \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0435\u043d\u044f\u0435\u043c \u0442\u043e,     # \u0447\u0442\u043e \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442     @property     def __annotations__(self):         return self.__annotate__()  # ...  def annotate_foo():     return {'x': int, 'y': MyType, 'return': float}  def foo(x = 3, y = \"abc\"):     ...  foo.__annotate__ = annotate_foo  class MyType:    ...  foo_y_annotation = foo.__annotations__['y']<\/code><\/pre>\n<p> \u042d\u0442\u0430 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0448\u0430\u0435\u0442 \u0442\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u043a\u0430\u043a \u043f\u0440\u044f\u043c\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0438 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u044d\u0442\u043e \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043c\u044b \u0438\u0437\u0431\u0435\u0433\u0430\u0435\u043c \u043d\u0435\u0437\u0430\u043c\u0435\u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u043b\u043d\u0443\u044e \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0443\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0438\u043d\u0442\u0440\u043e\u0441\u043f\u0435\u043a\u0446\u0438\u0438 \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0442\u0438\u043f\u043e\u0432 \u0432 \u0441\u0440\u0435\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p> <b><font color=\"#3AC1EF\">\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u043a\u0442:<\/font><\/b> \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 3.11 Python \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0442\u0438\u043f Self (<a href=\"https:\/\/peps.python.org\/pep-0673\/\">PEP 673<\/a>), \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u0441\u0432\u043e\u0435\u0433\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0440\u0435\u0448\u0430\u044f \u044d\u0442\u0443 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u0441\u0441\u044b\u043b\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u043d\u0430 \u0441\u0430\u043c\u0438\u0445 \u0441\u0435\u0431\u044f.<\/p>\n<pre><code class=\"python\">from typing import Self  class Foo:     def bar(self) -&gt; Self:         ...<\/code><\/pre>\n<p> <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b<\/font><\/h3>\n<p> <\/p>\n<ul>\n<li><a href=\"https:\/\/peps.python.org\/pep-0649\/#a-history-of-annotations\">A History Of Annotations<\/a><\/li>\n<li><a href=\"https:\/\/blog.derlin.ch\/python-type-hints-and-future-annotations\">Python, Type Hints, and Future Annotations<\/a><\/li>\n<li><a href=\"https:\/\/docs.python.org\/3\/library\/__future__.html\">__future__ \u2014 Future Statement Definitions<\/a><\/li>\n<li><a href=\"https:\/\/peps.python.org\/pep-0484\/\">PEP 484 \u2014 Type Hints<\/a><\/li>\n<li><a href=\"https:\/\/peps.python.org\/pep-0563\/\">PEP 563 \u2014 Postponed Evaluation of Annotations<\/a><\/li>\n<li><a href=\"https:\/\/peps.python.org\/pep-0649\/\">PEP 649 \u2014 Deferred Evaluation Of Annotations Using Descriptors<\/a><\/li>\n<li><a href=\"https:\/\/peps.python.org\/pep-0749\/\">PEP 749 \u2014 Implementing PEP 649<\/a><\/li>\n<\/ul>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">4. \u0414\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438<\/font><\/h2>\n<p> \u0410 \u0432\u044b \u0437\u043d\u0430\u043b\u0438, \u0447\u0442\u043e \u0432 Python \u0435\u0441\u0442\u044c <b><font color=\"#3AC1EF\">\u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438<\/font><\/b>? \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, <a href=\"https:\/\/docs.python.org\/3\/whatsnew\/3.12.html\">\u0432 Python 3.12<\/a> \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043d\u043e\u0432\u044b\u0439, \u0431\u043e\u043b\u0435\u0435 \u0438\u0437\u044f\u0449\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432.<\/p>\n<pre><code class=\"python\">class KVStore[K: str | int, V]:     def __init__(self) -&gt; None:         self.store: dict[K, V] = {}      def get(self, key: K) -&gt; V:         return self.store[key]      def set(self, key: K, value: V) -&gt; None:         self.store[key] = value  kv = KVStore[str, int]() kv.set(\"one\", 1) kv.set(\"two\", 2) kv.set(\"three\", 3)<\/code><\/pre>\n<p> \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0432 Python 3.5 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438 \u0431\u044b\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 <code>TypeVar<\/code>. \u041e\u0434\u043d\u0430\u043a\u043e <a href=\"https:\/\/peps.python.org\/pep-0695\/\">PEP 695<\/a> \u0434\u043b\u044f Python 3.12 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043b \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0442\u0438\u043f\u043e\u0432 \u0441 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u043c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c \u0434\u043b\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432, \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u043e\u0432 \u0442\u0438\u043f\u043e\u0432 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<pre><code class=\"python\"># \u0421\u0422\u0410\u0420\u042b\u0419 \u0421\u0418\u041d\u0422\u0410\u041a\u0421\u0418\u0421 \u2014 Python \u0441 3.5 \u043f\u043e 3.11 from typing import Generic, TypeVar  UnBounded = TypeVar(\"UnBounded\") Bounded = TypeVar(\"Bounded\", bound=int) Constrained = TypeVar(\"Constrained\", int, float)  class Foo(Generic[UnBounded, Bounded, Constrained]):     def __init__(self, x: UnBounded, y: Bounded, z: Constrained) -&gt; None:         self.x = x         self.y = y         self.z = z<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"python\"># \u041d\u041e\u0412\u042b\u0419 \u0421\u0418\u041d\u0422\u0410\u041a\u0421\u0418\u0421 - Python 3.12+ class Foo[UnBounded, Bounded: int, Constrained: int | float]:     def __init__(self, x: UnBounded, y: Bounded, z: Constrained) -&gt; None:         self.x = x         self.y = y         self.z = z<\/code><\/pre>\n<p> \u0421 \u044d\u0442\u0438\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0442\u0430\u043a\u0436\u0435 \u0431\u044b\u043b\u0430 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043c\u043e\u0449\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f <b><font color=\"#3AC1EF\">\u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432 \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 (variadic generics)<\/font><\/b>. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0442\u0438\u043f\u043e\u0432 \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439.<\/p>\n<pre><code class=\"python\">class Tuple[*Ts]:     def __init__(self, *args: *Ts) -&gt; None:         self.values = args  # \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043b\u044e\u0431\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0442\u0438\u043f\u043e\u0432! pair = Tuple[str, int](\"hello\", 42) triple = Tuple[str, int, bool](\"world\", 100, True)<\/code><\/pre>\n<p> \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 3.12 \u0432 Python \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043d\u043e\u0432\u044b\u0439 \u043a\u0440\u0430\u0442\u043a\u0438\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u043e\u0432 \u0442\u0438\u043f\u043e\u0432!<\/p>\n<pre><code class=\"python\"># \u0421\u0422\u0410\u0420\u042b\u0419 \u0421\u0418\u041d\u0422\u0410\u041a\u0421\u0418\u0421 \u2014 Python \u0441 3.5 \u043f\u043e 3.9 from typing import NewType Vector = NewType(\"Vector\", list[float])<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"python\"># \u041c\u0415\u041d\u0415\u0415 \u0421\u0422\u0410\u0420\u042b\u0419 \u0421\u0418\u041d\u0422\u0410\u041a\u0421\u0418\u0421 \u2014 Python \u0441 3.10 \u043f\u043e 3.11 from typing import TypeAlias Vector: TypeAlias = list[float]<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"python\"># \u041d\u041e\u0412\u042b\u0419 \u0421\u0418\u041d\u0422\u0410\u041a\u0421\u0418\u0421 \u2014 Python 3.12+ type Vector = list[float]<\/code><\/pre>\n<p> <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b<\/font><\/h3>\n<p> <\/p>\n<ul>\n<li><a href=\"https:\/\/arjancodes.com\/blog\/python-generics-syntax\/\">Blog on Python 3.12 Generics<\/a><\/li>\n<li><a href=\"https:\/\/realpython.com\/python312-typing\/\">Python 3.12 Preview: Static Typing Improvements<\/a><\/li>\n<li><a href=\"https:\/\/typing.python.org\/en\/latest\/spec\/generics.html\">Python Docs \u2014 Generics<\/a><\/li>\n<li><a href=\"https:\/\/peps.python.org\/pep-0695\/\">PEP 695 \u2014 Type Parameter Syntax<\/a><\/li>\n<\/ul>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">5. \u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u044b<\/font><\/h2>\n<p> \u041e\u0434\u043d\u0430 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0432\u0430\u0436\u043d\u044b\u0445 \u0444\u0438\u0447 Python (\u0438 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u0440\u0438\u0447\u0438\u043d \u0434\u043b\u044f \u0436\u0430\u043b\u043e\u0431) \u2014 \u044d\u0442\u043e \u0435\u0433\u043e <a href=\"https:\/\/realpython.com\/duck-typing-python\/\"><b><font color=\"#3AC1EF\">\u0443\u0442\u0438\u043d\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f<\/font><\/b><\/a>. \u0415\u0441\u0442\u044c \u0442\u0430\u043a\u0430\u044f \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u043a\u0430:<\/p>\n<p> \u00ab\u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u0443\u0442\u043a\u0430, \u043f\u043b\u0430\u0432\u0430\u0435\u0442 \u043a\u0430\u043a \u0443\u0442\u043a\u0430 \u0438 \u043a\u0440\u044f\u043a\u0430\u0435\u0442 \u043a\u0430\u043a \u0443\u0442\u043a\u0430, \u0442\u043e \u044d\u0442\u043e, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0438 \u0435\u0441\u0442\u044c \u0443\u0442\u043a\u0430\u00bb.<\/p>\n<p> \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441: <em>\u043a\u0430\u043a <b><font color=\"#3AC1EF\">\u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/font><\/b> \u0443\u0442\u0438\u043d\u0443\u044e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e?<\/em><\/p>\n<pre><code class=\"python\">class Duck:     def quack(self): print('Quack!')  class Person:     def quack(self): print(\"I'm quacking!\")  class Dog:     def bark(self): print('Woof!')  def run_quack(obj):     obj.quack()  run_quack(Duck())  # \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442! run_quack(Person())  # \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442! run_quack(Dog())  # \u0421\u0431\u043e\u0439 \u0441 AttributeError<\/code><\/pre>\n<p> \u0417\u0434\u0435\u0441\u044c \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 <b><font color=\"#3AC1EF\">\u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u044b<\/font><\/b>. \u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u044b (\u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 <b><font color=\"#3AC1EF\">Structural Subtyping<\/font><\/b>) \u2014 \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441\u044b \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 Python, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0435 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 <b><font color=\"#3AC1EF\">\u0431\u0435\u0437<\/font><\/b> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 \u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<pre><code class=\"python\">from typing import Protocol  class Quackable(Protocol):     def quack(self) -&gt; None:         ...  # \u041c\u043d\u043e\u0433\u043e\u0442\u043e\u0447\u0438\u0435 \u0437\u0434\u0435\u0441\u044c \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u043c\u0435\u0442\u043e\u0434\u0430  class Duck:     def quack(self): print('Quack!')  class Dog:     def bark(self): print('Woof!')  def run_quack(obj: Quackable):     obj.quack()  run_quack(Duck())  # \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442! run_quack(Dog())  # \u0421\u0431\u043e\u0439 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u041a\u041e\u041d\u0422\u0420\u041e\u041b\u042f \u0422\u0418\u041f\u041e\u0412 (\u043d\u0435 \u0432 \u0441\u0440\u0435\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f)<\/code><\/pre>\n<p> \u041f\u043e \u0441\u0443\u0442\u0438, \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442, \u0447\u0442\u043e <b><font color=\"#3AC1EF\">\u043c\u043e\u0436\u0435\u0442<\/font><\/b> \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0430\u0448 \u043e\u0431\u044a\u0435\u043a\u0442, \u0430 \u043d\u0435 \u0447\u0442\u043e \u043e\u043d <b><font color=\"#3AC1EF\">\u0434\u0435\u043b\u0430\u0435\u0442<\/font><\/b>. \u041e\u043d\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0441\u0442\u0443\u043b\u0438\u0440\u0443\u044e\u0442, \u0447\u0442\u043e \u043f\u043e\u043a\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438\u043b\u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f, \u043e\u043d \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c, \u0432\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0438\u043b\u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p> <b><font color=\"#3AC1EF\">\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430:<\/font><\/b> \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 <code>@runtime_checkable<\/code>, \u0435\u0441\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0440\u044f\u0434\u0443 \u0441 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 <code>isinstance()<\/code>!<\/p>\n<pre><code class=\"python\">@runtime_checkable class Drawable(Protocol):     def draw(self) -&gt; None:         ...<\/code><\/pre>\n<p> <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b<\/font><\/h3>\n<p> <\/p>\n<ul>\n<li><a href=\"https:\/\/realpython.com\/python-protocol\/\">Python Protocols: Leveraging Structural Subtyping<\/a><\/li>\n<li><a href=\"https:\/\/mypy.readthedocs.io\/en\/stable\/protocols.html\">MyPy: Protocols and structural subtyping<\/a><\/li>\n<li><a href=\"https:\/\/typing.python.org\/en\/latest\/spec\/protocol.html\">Python Docs \u2014 Protocols<\/a><\/li>\n<li><a href=\"https:\/\/peps.python.org\/pep-0544\/\">PEP 544 \u2014 Protocols: Structural subtyping<\/a><\/li>\n<\/ul>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">6. \u041c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u044b \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430<\/font><\/h2>\n<p> <b><font color=\"#3AC1EF\">\u041c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u044b \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 (Context Manager)<\/font><\/b> \u2014 \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b: <code>__enter__()<\/code> \u0438 <code>__exit__()<\/code>. \u041c\u0435\u0442\u043e\u0434 <code>__enter__()<\/code> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u0445\u043e\u0434\u0438\u043c \u0432 \u0431\u043b\u043e\u043a <code>with<\/code>, \u0430 \u043c\u0435\u0442\u043e\u0434 <code>__exit__()<\/code> \u2014 \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0435\u0433\u043e \u043f\u043e\u043a\u0438\u0434\u0430\u0435\u043c (\u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435).<\/p>\n<p> <b><font color=\"#3AC1EF\"><code>Contextlib<\/code><\/font><\/b> \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044f \u0432\u0435\u0441\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0431\u043e\u0439\u043b\u0435\u0440\u043f\u043b\u0435\u0439\u0442\u0430 \u0432 \u0435\u0434\u0438\u043d\u044b\u0439 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440.<\/p>\n<pre><code class=\"python\"># \u0421\u0422\u0410\u0420\u042b\u0419 \u0421\u0418\u041d\u0422\u0410\u041a\u0421\u0418\u0421 \u2014 \u0422\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0432 \u0441\u0442\u0438\u043b\u0435 \u041e\u041e\u041f class retry:     def __enter__(self):         print(\"Entering Context\")      def __exit__(self, exc_type, exc_val, exc_tb):         print(\"Exiting Context\")<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"python\"># \u041d\u041e\u0412\u042b\u0419 \u0421\u0418\u041d\u0422\u0410\u041a\u0421\u0418\u0421 \u2014 \u041d\u043e\u0432\u044b\u0439 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 contextlib import contextlib  @contextlib.contextmanager def retry():     print(\"Entering Context\")     yield     print(\"Exiting Context\")<\/code><\/pre>\n<p> \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u043c <code>@contextlib.contextmanager<\/code>, \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0434\u043e <code>yield<\/code> \u0438 \u043a\u043e\u0434 \u043f\u043e\u0434\u0447\u0438\u0441\u0442\u043a\u0438 \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u0433\u043e. \u0412\u0441\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 yield \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443. \u0412\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e.<\/p>\n<p> \u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>yield<\/code> \u043f\u0440\u0438\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0443 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u0430\u0448\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0430 \u043f\u0430\u0443\u0437\u0443 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c\u0441\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u043c\u0443 \u0432 \u0431\u043b\u043e\u043a\u0435 <code>with<\/code>.<\/p>\n<pre><code class=\"python\">import contextlib  @contextlib.contextmanager def context():     # \u0417\u0434\u0435\u0441\u044c \u043a\u043e\u0434 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438     setup()     yield (...)  # \u0412\u0441\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0431\u043b\u043e\u043a\u0443 with     # \u0417\u0434\u0435\u0441\u044c \u043a\u043e\u0434 \u043e\u0447\u0438\u0441\u0442\u043a\u0438     takedown()<\/code><\/pre>\n<p> \u0412 \u0446\u0435\u043b\u043e\u043c, \u044d\u0442\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0430\u0442\u043a\u0438\u0439 \u0438 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0432 Python.<\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b<\/font><\/h3>\n<p> <\/p>\n<ul>\n<li><a href=\"https:\/\/realpython.com\/python-with-statement\/\">Context Managers and Python\u2019s with Statement<\/a><\/li>\n<li><a href=\"https:\/\/book.pythontips.com\/en\/latest\/context_managers.html\">Python Tips: Context Manager<\/a><\/li>\n<li><a href=\"https:\/\/docs.python.org\/3\/library\/contextlib.html\">Python Docs: contextlib \u2014 Utilities for with-statement contexts<\/a><\/li>\n<\/ul>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">7. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u043e\u0435 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c<\/font><\/h2>\n<p> \u041f\u043e\u044f\u0432\u0438\u0432\u0448\u0435\u0435\u0441\u044f \u0432 <a href=\"https:\/\/docs.python.org\/3\/whatsnew\/3.10.html\">Python 3.10<\/a> <b><font color=\"#3AC1EF\">\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u043e\u0435 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c (Structural Pattern Matching)<\/font><\/b> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u043d\u0430 Python \u043c\u043e\u0449\u043d\u0443\u044e \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0443 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0435. \u0412 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u043c \u0432\u0438\u0434\u0435 \u0435\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">match value:     case pattern1:         # \u043a\u043e\u0434, \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 pattern1     case pattern2:         # \u043a\u043e\u0434, \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 pattern2     case _:         # \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u0447\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e)<\/code><\/pre>\n<p> \u0420\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u0435\u0433\u043e \u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0441 <b><font color=\"#3AC1EF\">\u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439<\/font><\/b>! \u0421\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0437\u0430 \u043e\u0434\u0438\u043d \u0448\u0430\u0433.<\/p>\n<pre><code class=\"python\"># \u0414\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439 match point:     case (0, 0):         return \"Origin\"     case (0, y):         return f\"Y-axis at {y}\"     case (x, 0):         return f\"X-axis at {x}\"     case (x, y):         return f\"Point at ({x}, {y})\"<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"python\"># \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 OR (|) \u0434\u043b\u044f \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 match day:     case (\"Monday\"           | \"Tuesday\"           | \"Wednesday\"           | \"Thursday\"           | \"Friday\"):         return \"Weekday\"     case \"Saturday\" | \"Sunday\":         return \"Weekend\"<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"python\"># \u0413\u0440\u0430\u043d\u0438\u0447\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0441\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438 if match temperature:     case temp if temp &lt; 0:         return \"Freezing\"     case temp if temp &lt; 20:         return \"Cold\"     case temp if temp &lt; 30:         return \"Warm\"     case _:         return \"Hot\"<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"python\"># \u0421\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 (*) match numbers:     case [f]:         return f\"First: {f}\"     case [f, l]:         return f\"First: {f}, Last: {l}\"     case [f, *m, l]:         return f\"First: {f}, Middle: {m}, Last: {l}\"     case []:         return \"Empty list\"<\/code><\/pre>\n<p> \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c match-case \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0444\u0438\u0447\u0430\u043c\u0438 Python, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441 <b><font color=\"#3AC1EF\"><a href=\"https:\/\/realpython.com\/python-walrus-operator\/\">\u043c\u043e\u0440\u0436\u043e\u0432\u044b\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438<\/a><\/font><\/b> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0435\u0449\u0451 \u0431\u043e\u043b\u0435\u0435 \u043c\u043e\u0449\u043d\u044b\u0445 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432.<\/p>\n<pre><code class=\"python\"># \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u043f\u0430\u043a\u0435\u0442\u0430 packet: list[int] = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]  match packet:     case [c1, c2, *data, footer] if (  # \u0414\u0435\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u0443\u0435\u043c \u043f\u0430\u043a\u0435\u0442 \u043d\u0430 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a, \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043a\u043e\u043d\u0435\u0446         (checksum := c1 + c2) == sum(data) and  # \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u043e\u0439 \u0441\u0443\u043c\u043c\u044b         len(data) == footer  # \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445     ):         print(f\"Packet received: {data} (Checksum: {checksum})\")     case [c1, c2, *data]:  # \u0421\u043b\u0443\u0447\u0430\u0439 \u0441\u0431\u043e\u044f, \u043a\u043e\u0433\u0434\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u0430, \u043d\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u0430\u044f \u0441\u0443\u043c\u043c\u0430 \u043d\u0435\u0432\u0435\u0440\u043d\u0430         print(f\"Packet received: {data} (Checksum Failed)\")     case [_, *__]:  # \u0421\u043b\u0443\u0447\u0430\u0439 \u0441\u0431\u043e\u044f, \u043a\u043e\u0433\u0434\u0430 \u043f\u0430\u043a\u0435\u0442 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439         print(\"Invalid packet length\")     case []:  # \u0421\u043b\u0443\u0447\u0430\u0439 \u0441\u0431\u043e\u044f, \u043a\u043e\u0433\u0434\u0430 \u043f\u0430\u043a\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0439         print(\"Empty packet\")     case _:  # \u0421\u043b\u0443\u0447\u0430\u0439 \u0441\u0431\u043e\u044f, \u043a\u043e\u0433\u0434\u0430 \u043f\u0430\u043a\u0435\u0442 \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u0435\u043d         print(\"Invalid packet\")<\/code><\/pre>\n<p> <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b<\/font><\/h3>\n<p> <\/p>\n<ul>\n<li><a href=\"https:\/\/realpython.com\/structural-pattern-matching\/\">Structural Pattern Matching in Python<\/a><\/li>\n<li><a href=\"https:\/\/benhoyt.com\/writings\/python-pattern-matching\/\">Structural pattern matching in Python 3.10<\/a><\/li>\n<li><a href=\"https:\/\/stackoverflow.com\/questions\/70815197\/how-to-do-structural-pattern-matching-in-python-3-10-with-a-type-to-match\">Good StackOverflow Thread<\/a><\/li>\n<li><a href=\"https:\/\/docs.python.org\/3\/reference\/compound_stmts.html#match\">Python Docs: The match statement<\/a><\/li>\n<li><a href=\"https:\/\/peps.python.org\/pep-0634\/\">PEP 634 \u2014 Structural Pattern Matching: Specification<\/a><\/li>\n<li><a href=\"https:\/\/peps.python.org\/pep-0636\/\">PEP 636 \u2014 Structural Pattern Matching: Tutorial<\/a><\/li>\n<\/ul>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">8. \u0421\u043b\u043e\u0442\u044b Python<\/font><\/h2>\n<p> <b><font color=\"#3AC1EF\">\u0421\u043b\u043e\u0442\u044b (Slots)<\/font><\/b> \u2014 \u044d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 Python \u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043d\u0435\u043c\u0443.<\/p>\n<p> <b><font color=\"#3AC1EF\">TLDR:<\/font><\/b> \u0441\u043b\u043e\u0442\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044e\u0442 \u0438 \u0443\u0441\u043a\u043e\u0440\u044f\u044e\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0432 \u0441\u0440\u0435\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"python\">class Person:     __slots__ = ('name', 'age')      def __init__(self, name, age):         self.name = name         self.age = age<\/code><\/pre>\n<p> \u041a\u043b\u0430\u0441\u0441\u044b Python \u0445\u0440\u0430\u043d\u044f\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u0435 <code>__dict__<\/code>, \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0438\u0441\u043a \u043f\u043e \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435.<\/p>\n<p> <code>__slots__<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u043e\u0445\u043e\u0436\u0443\u044e \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u0433\u0434\u0435 \u043f\u043e\u0438\u0441\u043a \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0437\u0430 \u0432\u0440\u0435\u043c\u044f O(1), \u0447\u0442\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0441\u043a\u043e\u0440\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u043d\u0430 Python.<\/p>\n<pre><code class=\"python\"># \u0411\u0435\u0437 __slots__ class FooBar:     def __init__(self):         self.a = 1         self.b = 2         self.c = 3  f = FooBar() print(f.__dict__)  # {'a': 1, 'b': 2, 'c': 3}<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"python\"># \u0421\u043e __slots__ class FooBar:     __slots__ = ('a', 'b', 'c')      def __init__(self):         self.a = 1         self.b = 2         self.c = 3  f = FooBar() print(f.__dict__)  # AttributeError print(f.__slots__)  # ('a', 'b', 'c')<\/code><\/pre>\n<p> \u041f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0432\u0435\u0434\u0443\u0442\u0441\u044f \u0441\u043f\u043e\u0440\u044b \u043e \u0442\u043e\u043c, \u0441\u0442\u043e\u0438\u0442 \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <code>__slots__<\/code>, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u0438 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u044e\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043d\u0435 \u043f\u0440\u0438\u043d\u043e\u0441\u044f \u0438\u043b\u0438 \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u043f\u0440\u0438\u043d\u043e\u0441\u044f \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0432 \u0441\u0432\u043e\u0439 \u0430\u0440\u0441\u0435\u043d\u0430\u043b \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b<\/font><\/h3>\n<p> <\/p>\n<ul>\n<li><a href=\"https:\/\/wiki.python.org\/moin\/UsingSlots\">Using Slots \u2014 Python Wiki<\/a><\/li>\n<li><a href=\"https:\/\/medium.com\/@apps.merkurev\/dont-forget-about-slots-in-python-c397f414c490\">Don\u2019t forget about __slots__ in Python!<\/a><\/li>\n<li><a href=\"https:\/\/stackoverflow.com\/questions\/472000\/usage-of-slots\">StackOverflow \u2014 Usage of __slots__<\/a><\/li>\n<\/ul>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">9. \u041c\u0435\u043b\u043e\u0447\u0438 Python<\/font><\/h2>\n<p> <\/p>\n<blockquote><p>\u0421\u0430\u043c\u043e \u043f\u043e \u0441\u0435\u0431\u0435 \u044d\u0442\u043e \u043d\u0435 \u00ab\u0444\u0438\u0447\u0430\u00bb Python \u0438 \u043d\u0435 \u00ab\u0441\u043e\u0432\u0435\u0442\u00bb, \u0430 \u043d\u0430\u0431\u043e\u0440 \u043a\u0440\u0430\u0442\u043a\u0438\u0445 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043e\u043a \u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0435, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u0445 \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u0447\u0438\u0441\u0442\u043e\u0442\u0443 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b \u043d\u0430 Python.<\/p><\/blockquote>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">9.1 \u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b For-else<\/font><\/h2>\n<p> \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0446\u0438\u043a\u043b for \u0431\u0435\u0437 break, \u0442\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <b><font color=\"#3AC1EF\">\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 for-else<\/font><\/b> \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439.<\/p>\n<pre><code class=\"python\"># ===== \u041d\u0435 \u043f\u0438\u0448\u0438\u0442\u0435 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 ===== found_server = False  # \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u043d\u0430\u0439\u0434\u0435\u043d \u043b\u0438 \u0441\u0435\u0440\u0432\u0435\u0440 for server in servers:     if server.check_availability():         primary_server = server         found_server = True  # \u041f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u0444\u043b\u0430\u0433\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 True         break if not found_server:     # \u0415\u0441\u043b\u0438 \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440     primary_server = backup_server  # \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c deploy_application(primary_server)<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"python\"># ===== \u041f\u0438\u0448\u0438\u0442\u0435 \u0442\u0430\u043a ===== for server in servers:     if server.check_availability():         primary_server = server         break else:     # \u0415\u0441\u043b\u0438 \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440     primary_server = backup_server  # \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c deploy_application(primary_server)<\/code><\/pre>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">9.2 \u041c\u043e\u0440\u0436\u043e\u0432\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440<\/font><\/h2>\n<p> \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0432 \u043e\u0434\u043d\u043e\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438, \u0442\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 <b><font color=\"#3AC1EF\">\u043c\u043e\u0440\u0436\u043e\u0432\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440<\/font><\/b> (\u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u0432 Python 3.8 \u0438 <a href=\"https:\/\/peps.python.org\/pep-0572\/\">PEP 572<\/a>).<\/p>\n<blockquote><p>\u041c\u043e\u0440\u0436\u043e\u0432\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043e\u043d\u043e <b><font color=\"#3AC1EF\"><code>not None<\/code><\/font><\/b>.<\/p><\/blockquote>\n<p> <\/p>\n<pre><code class=\"python\"># ===== \u041d\u0435 \u043f\u0438\u0448\u0438\u0442\u0435 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 ===== response = get_user_input() if response:     print('You pressed:', response) else:     print('You pressed nothing')<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"python\"># ===== \u041f\u0438\u0448\u0438\u0442\u0435 \u0442\u0430\u043a ===== if response := get_user_input():     print('You pressed:', response) else:     print('You pressed nothing')<\/code><\/pre>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">9.3 \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043f\u043e \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0439 \u0441\u0445\u0435\u043c\u0435<\/font><\/h2>\n<p> <b><font color=\"#3AC1EF\">\u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043f\u043e \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0439 \u0441\u0445\u0435\u043c\u0435 (Short-circuit Evaluation)<\/font><\/b> \u2014 \u044d\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u00ab\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0433\u043e\u00bb \u0438\u043b\u0438 \u00ab\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u0434\u043b\u0438\u043d\u043d\u043e\u0433\u043e\u00bb \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439. \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b <code>or<\/code> \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0442\u044c \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0438!<\/p>\n<pre><code class=\"python\"># ===== \u041d\u0435 \u043f\u0438\u0448\u0438\u0442\u0435 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 ===== username, full_name, first_name = get_user_info()  if username is not None:     display_name = username elif full_name is not None:     display_name = full_name elif first_name is not None:     display_name = first_name else:     display_name = \"Anonymous\"<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"python\"># ===== \u041f\u0438\u0448\u0438\u0442\u0435 \u0442\u0430\u043a ===== username, full_name, first_name = get_user_info()  display_name = username or full_name or first_name or \"Anonymous\"<\/code><\/pre>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">9.4 \u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0438<\/font><\/h2>\n<p> \u041d\u0430\u043a\u043e\u043d\u0435\u0446, Python \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 <b><font color=\"#3AC1EF\">\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0442\u044c \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f<\/font><\/b>, \u0447\u0442\u043e\u0431\u044b \u0443\u043a\u043e\u0440\u043e\u0442\u0438\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0432 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0435 integer, \u0434\u0435\u043b\u0430\u044f \u0438\u0445 \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c\u0438, \u0447\u0435\u043c \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u0435 \u0431\u0443\u043b\u0435\u0432\u044b \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"python\"># ===== \u041d\u0435 \u043f\u0438\u0448\u0438\u0442\u0435 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 ===== if 0 &lt; x and x &lt; 10:     print(\"x is between 0 and 10\")<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"python\"># ===== \u041f\u0438\u0448\u0438\u0442\u0435 \u0442\u0430\u043a ===== if 0 &lt; x &lt; 10:  # \u0412\u043c\u0435\u0441\u0442\u043e if 0 &lt; x and x &lt; 10     print(\"x is between 0 and 10\")<\/code><\/pre>\n<p> <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b<\/font><\/h3>\n<p> <\/p>\n<ul>\n<li><a href=\"https:\/\/book.pythontips.com\/en\/latest\/for_-_else.html\">for\/else \u2014 Python Tips<\/a><\/li>\n<li><a href=\"https:\/\/realpython.com\/python-walrus-operator\/\">The Walrus Operator: Python\u2019s Assignment Expressions<\/a><\/li>\n<li><a href=\"https:\/\/peps.python.org\/pep-0572\/\">PEP 572 \u2014 Assignment Expressions<\/a><\/li>\n<li><a href=\"https:\/\/realpython.com\/python-or-operator\/#default-values-for-variables\">Using the \u201cor\u201d Boolean Operator in Python<\/a><\/li>\n<li><a href=\"https:\/\/mathspp.com\/blog\/pydonts\/chaining-comparison-operators\">Chaining Comparison Operators<\/a><\/li>\n<\/ul>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">10. \u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 f-\u0441\u0442\u0440\u043e\u043a<\/font><\/h2>\n<p> <b><font color=\"#3AC1EF\">F-\u0441\u0442\u0440\u043e\u043a\u0438<\/font><\/b> Python \u0443\u0436\u0435 \u043d\u0438 \u0434\u043b\u044f \u043a\u043e\u0433\u043e \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0435\u043a\u0440\u0435\u0442\u043e\u043c. \u042d\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439, \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 \u0441\u0442\u0440\u043e\u043a\u0438, \u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u0432 Python 3.6 \u0438 PEP 498.<\/p>\n<p> \u041d\u043e \u0437\u043d\u0430\u043b\u0438 \u043b\u0438 \u0432\u044b, \u0447\u0442\u043e f-\u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435? \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u0439\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <b><font color=\"#3AC1EF\">Format Mini-Language<\/font><\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0437\u0430 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u0440\u043e\u043a.<\/p>\n<pre><code class=\"python\">print(f\"{' [ Run Status ] ':=^50}\") print(f\"[{time:%H:%M:%S}] Training Run {run_id=} status: {progress:.1%}\") print(f\"Summary: {total_samples:,} samples processed\") print(f\"Accuracy: {accuracy:.4f} | Loss: {loss:#.3g}\") print(f\"Memory: {memory \/ 1e9:+.2f} GB\")<\/code><\/pre>\n<p> <b><font color=\"#3AC1EF\">\u0412\u044b\u0432\u043e\u0434:<\/font><\/b><\/p>\n<pre><code class=\"plaintext\">=================== [ Run Status ] =================== [11:16:37] Training Run run_id=42 status: 87.4% Summary: 12,345,678 samples processed Accuracy: 0.9876 | Loss: 0.0123 Memory: +2.75 GB<\/code><\/pre>\n<p> \u0421 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0447\u0438\u0441\u0435\u043b (\u043a\u0430\u043a \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <code>str.format<\/code>), \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a, \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b datetime \u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435! \u0418 \u0432\u0441\u0451 \u044d\u0442\u043e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 f-\u0441\u0442\u0440\u043e\u043a.<\/p>\n<h2><font color=\"#3AC1EF\">\u041e\u0431\u044b\u0447\u043d\u044b\u0435 f-\u0441\u0442\u0440\u043e\u043a\u0438<\/font><\/h2>\n<p> <\/p>\n<pre><code class=\"python\">print(f\"Hello {item}!\")<\/code><\/pre>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">\u041e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/font><\/h2>\n<p> <\/p>\n<pre><code class=\"python\">print(f\"{name=}, {age=}\")<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"python\">name='Claude', age=3<\/code><\/pre>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">\u0424\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0447\u0438\u0441\u0435\u043b<\/font><\/h2>\n<p> <\/p>\n<pre><code class=\"python\">print(f\"Pi: {pi:.2f}\") print(f\"Avogadro: {avogadro:.2e}\") print(f\"Big Number: {big_num:,}\") print(f\"Hex: {num:#0x}\") print(f\"Number: {num:09}\")<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"plaintext\">Pi: 3.14 Avogadro: 6.02e+23 Big Number: 1,000,000 Hex: 0x1a4 Number: 000000420<\/code><\/pre>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">\u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a<\/font><\/h2>\n<p> <\/p>\n<pre><code class=\"python\">print(f\"Left: |{word:&lt;10}|\") print(f\"Right: |{word:&gt;10}|\") print(f\"Center: |{word:^10}|\") print(f\"Center *: |{word:*^10}|\")<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"python\">Left: |Python    | Right: |    Python| Center: |  Python  | Center *: |**Python**|<\/code><\/pre>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">\u0424\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u0442<\/font><\/h2>\n<p> <\/p>\n<pre><code class=\"python\">print(f\"Date: {now:%Y-%m-%d}\") print(f\"Time: {now:%H:%M:%S}\")<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"plaintext\">Date: 2025-03-10 Time: 14:30:59<\/code><\/pre>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">\u0424\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<\/font><\/h2>\n<p> <\/p>\n<pre><code class=\"python\">print(f\"Progress: {progress:.1%}\")<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"plaintext\">Progress: 75.0%<\/code><\/pre>\n<p> <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b<\/font><\/h3>\n<p> <\/p>\n<ul>\n<li><a href=\"https:\/\/realpython.com\/python-f-strings\/\">Python\u2019s F-String for String Interpolation and Formatting<\/a><\/li>\n<li><a href=\"https:\/\/realpython.com\/python-format-mini-language\/\">Python\u2019s Format Mini-Language for Tidy Strings<\/a><\/li>\n<li><a href=\"https:\/\/docs.python.org\/3\/tutorial\/inputoutput.html\">Python Docs \u2014 Input and Output<\/a><\/li>\n<li><a href=\"https:\/\/peps.python.org\/pep-0498\/\">PEP 498 \u2014 Literal String Interpolation<\/a><\/li>\n<\/ul>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">11. cache\/lru_cache<\/font><\/h2>\n<p> \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 <strong><code>@cache<\/code><\/strong>, \u0447\u0442\u043e\u0431\u044b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f! (\u0412 Python 3.9 \u043e\u043d \u0432\u044b\u0442\u0435\u0441\u043d\u0438\u043b <code>@lru_cache<\/code>.)<\/p>\n<pre><code class=\"python\">from functools import cache  @cache def fib(n):     return n if n &lt; 2 else fib(n-1) + fib(n-2)<\/code><\/pre>\n<p> \u0412 Python 3.2 <code>@lru_cache<\/code> \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044f <code>functools<\/code> \u0438 \u0431\u044b\u043b \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0438 \u0447\u0438\u0441\u0442\u043e\u0439 \u043c\u0435\u043c\u043e\u0438\u0437\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u0412 Python 3.9 \u0431\u044b\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d <code>@cache<\/code>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u0433\u043e \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0441 \u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043a\u043e\u0434\u0430. \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043d\u0430\u0434 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u043a\u044d\u0448\u0430, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>lru_cache<\/code>.<\/p>\n<pre><code class=\"python\">FIB_CACHE = {}  # \u0421 \u0440\u0443\u0447\u043d\u044b\u043c \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c def fib(n):     if n in FIB_CACHE:         return FIB_CACHE[n]     if n &lt;= 2:         return 1     FIB_CACHE[n] = fib(n - 1) + fib(n - 2)     return FIB_CACHE[n]<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"python\">from functools import lru_cache  # \u0422\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434 \u0441 lru_cache @lru_cache(maxsize=None) def fib(n):     return n if n &lt; 2 else fib(n-1) + fib(n-2)<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"python\">from functools import cache  # \u0422\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434 \u0441 \u043d\u043e\u0432\u044b\u043c \u043a\u044d\u0448\u0435\u043c Python 3.9 @cache def fib(n):     return n if n &lt; 2 else fib(n-1) + fib(n-2)<\/code><\/pre>\n<p> <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b<\/font><\/h3>\n<p> <\/p>\n<ul>\n<li><a href=\"https:\/\/www.datacamp.com\/tutorial\/python-cache-introduction\">Python Cache: Two Simple Methods<\/a><\/li>\n<li><a href=\"https:\/\/realpython.com\/lru-cache-python\/\">(outdated) Caching in Python Using the LRU Cache Strategy<\/a><\/li>\n<li><a href=\"https:\/\/docs.python.org\/3\/library\/functools.html#functools.cache\">Python Docs \u2014 @functools.cache<\/a><\/li>\n<li><a href=\"https:\/\/docs.python.org\/3\/library\/functools.html#functools.lru_cache\">Python Docs \u2014 @functools.lru_cache<\/a><\/li>\n<\/ul>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">12. Python Futures<\/font><\/h2>\n<p> \u0410 \u0432\u044b \u0437\u043d\u0430\u043b\u0438, \u0447\u0442\u043e \u0432 Python \u0435\u0441\u0442\u044c \u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0432 \u0441\u0442\u0438\u043b\u0435 <code>Promise<\/code>?<\/p>\n<pre><code class=\"python\">from concurrent.futures import Future  # \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043e\u0431\u044a\u0435\u043a\u0442 Future future = Future()  # \u0417\u0430\u0434\u0430\u0451\u043c \u0435\u043c\u0443 \u043b\u044e\u0431\u043e\u0439 \u043d\u0443\u0436\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 future.set_result(\"Hello from the future!\")  # \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 print(future.result())  # \"Hello from the future!\"<\/code><\/pre>\n<p> \u041c\u043e\u0434\u0443\u043b\u044c <b><font color=\"#3AC1EF\"><code>concurrent.futures<\/code><\/font><\/b> \u044f\u0437\u044b\u043a\u0430 Python \u0434\u0430\u0451\u0442 \u043d\u0430\u043c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043d\u0430\u0434 async-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438, \u043a\u0430\u043a Promise \u0432 JS. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u044f\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u044b\u0435 \u043f\u0440\u0438 \u0433\u043e\u0442\u043e\u0432\u043d\u043e\u0441\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 (\u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a <code>.then()<\/code> \u0432 JS).<\/p>\n<pre><code class=\"python\">from concurrent.futures import Future  future = Future()  # \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0414\u041e \u0438\u043b\u0438 \u041f\u041e\u0421\u041b\u0415 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f! future.add_done_callback(lambda f: print(f\"Got: {f.result()}\"))  future.set_result(\"Async result\") # \u0412\u044b\u0432\u043e\u0434: \"Got: Async result\"  future.add_done_callback(lambda f: print(f\"After: {f.result()}\")) # \u0412\u044b\u0432\u043e\u0434: \"After: Async result\"<\/code><\/pre>\n<p> \u0422\u0430\u043a\u0436\u0435 \u0443 Python Futures \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u044b \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439, \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u043e\u0432 \u0438 \u043f\u043e\u043b\u043d\u043e\u0439 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u0430\u0434\u0430\u0447.<\/p>\n<pre><code class=\"python\">from concurrent.futures import Future import time, threading  # \u0421\u043e\u0437\u0434\u0430\u0451\u043c future \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0438\u043c \u0432\u0440\u0443\u0447\u043d\u0443\u044e future = Future()  # \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0444\u043e\u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 def background_task():     time.sleep(2)     future.set_result(\"Done!\")  thread = threading.Thread(target=background_task) thread.daemon = True thread.start()  # \u041f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f print(f\"Cancelled: {future.cancel()}\")  # \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, False, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u043e\u0441\u044c  try:     # \u0416\u0434\u0451\u043c \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 0,5 \u0441\u0435\u043a\u0443\u043d\u0434\u044b     result = future.result(timeout=0.5) except TimeoutError:     print(\"Timed out!\")  # \u0421\u043e\u0437\u0434\u0430\u0451\u043c future \u0441\u0431\u043e\u044f err_future = Future() err_future.set_exception(ValueError(\"Failed\")) print(f\"Has error: {bool(err_future.exception())}\")<\/code><\/pre>\n<p> \u041a\u0430\u043a \u0438 \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c JS, \u043c\u043e\u0434\u0443\u043b\u044c <code>asyncio<\/code> \u0438\u043c\u0435\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 Future, \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0441 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c <code>async\/await<\/code> Python:<\/p>\n<pre><code class=\"python\">import asyncio  async def main():     future = asyncio.Future()      # \u0417\u0430\u0434\u0430\u0451\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438     asyncio.create_task(set_after_delay(future))      # Await, \u043a\u0430\u043a Promise \u0432 JS!     result = await future     print(result)  # \"Worth the wait!\"  async def set_after_delay(future):     await asyncio.sleep(1)     future.set_result(\"Worth the wait!\")  asyncio.run(main())<\/code><\/pre>\n<p> \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447, \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0438\u0445 \u043e\u0442 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 CPU \u0438\u043b\u0438 \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430, <code>ThreadPoolExecutor<\/code> \u043c\u043e\u0436\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c future \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043c\u0438.<\/p>\n<pre><code class=\"python\">from concurrent.futures import ThreadPoolExecutor import time  def slow_task():     time.sleep(1)     return \"Done!\"  with ThreadPoolExecutor() as executor:     # \u041d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 Future     future = executor.submit(slow_task)      # \u041f\u043e\u043a\u0430 \u043e\u0436\u0438\u0434\u0430\u0435\u043c, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0434\u0440\u0443\u0433\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443...     print(\"Working...\")      # \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438     print(future.result())<\/code><\/pre>\n<p> <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b<\/font><\/h3>\n<p> <\/p>\n<ul>\n<li><a href=\"https:\/\/medium.com\/@smrati.katiyar\/introduction-to-concurrent-futures-in-python-009fe1d4592c\">Introduction to concurrent.futures in Python<\/a><\/li>\n<li><a href=\"https:\/\/alexwlchan.net\/2019\/adventures-with-concurrent-futures\/\">Adventures in Python with concurrent.futures<\/a><\/li>\n<li><a href=\"https:\/\/docs.python.org\/3\/library\/asyncio-future.html\">Python Docs \u2014 Futures<\/a><\/li>\n<li><a href=\"https:\/\/docs.python.org\/3\/library\/concurrent.futures.html\">Python Docs \u2014 concurrent.futures<\/a><\/li>\n<\/ul>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">13. \u041f\u0440\u043e\u043a\u0441\u0438-\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430<\/font><\/h2>\n<p> \u0410 \u0432\u044b \u0437\u043d\u0430\u043b\u0438, \u0447\u0442\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043a\u0430\u043a \u043c\u0435\u0442\u043e\u0434\u044b <b><font color=\"#3AC1EF\">\u0418<\/font><\/b> \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430? <em>\u042d\u0442\u043e \u043d\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0444\u0438\u0447\u0430 Python<\/em>, \u0430 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0445\u0438\u0442\u0440\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e dunder-\u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u0432 Python.<\/p>\n<blockquote><p>(\u0423\u0447\u0442\u0438\u0442\u0435, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435)<\/p><\/blockquote>\n<p> <\/p>\n<pre><code class=\"python\">from typing import Callable, Generic, TypeVar, ParamSpec, Self  P = ParamSpec(\"P\") R = TypeVar(\"R\") T = TypeVar(\"T\")  class ProxyProperty(Generic[P, R]):     func: Callable[P, R]     instance: object      def __init__(self, func: Callable[P, R]) -&gt; None:         self.func = func      def __get__(self, instance: object, _=None) -&gt; Self:         self.instance = instance         return self      def __call__(self, *args: P.args, **kwargs: P.kwargs) -&gt; R:         return self.func(self.instance, *args, **kwargs)      def __repr__(self) -&gt; str:         return self.func(self.instance)  def proxy_property(func: Callable[P, R]) -&gt; ProxyProperty[P, R]:     return ProxyProperty(func)  class Container:     @proxy_property     def value(self, val: int = 5) -&gt; str:         return f\"The value is: {val}\"  # \u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f  c = Container() print(c.value)      # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442: The value is: 5 print(c.value(7))   # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442: The value is: 7<\/code><\/pre>\n<p> \u0412\u0441\u0451 \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a <a href=\"https:\/\/docs.python.org\/3\/howto\/descriptor.html\">Descriptor Protocol<\/a> Python:<\/p>\n<ol>\n<li>\u041c\u0435\u0442\u043e\u0434 <code>__get__<\/code> \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 <code>ProxyProperty<\/code> \u0432 <b><font color=\"#3AC1EF\">\u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440<\/font><\/b>.<\/li>\n<li>\u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a <code>c.value<\/code> Python \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>__get__<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>self<\/code> (\u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430).<\/li>\n<li>\u041c\u0435\u0442\u043e\u0434 <code>__repr__<\/code> \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c (\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e).<\/li>\n<li>\u041c\u0435\u0442\u043e\u0434 <code>__call__<\/code> \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0432\u044b\u0437\u043e\u0432\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438.<\/li>\n<\/ol>\n<p> \u042d\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0434\u0432\u043e\u0439\u043d\u043e\u0433\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0418 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044e!<\/p>\n<p> \u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435 API, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 \u043c\u043e\u0436\u0435\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f, \u0438\u043b\u0438 \u0435\u0441\u043b\u0438 \u0438\u043c \u043d\u0443\u0436\u043d\u044b \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u0440\u0430\u0437\u0443\u043c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043d\u043e \u0432 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<blockquote><p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u043a \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <b><font color=\"#3AC1EF\">\u043f\u0440\u043e\u043a\u0441\u0438-\u0441\u0432\u043e\u0439\u0441\u0442\u0432<\/font><\/b>, \u0442\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <code>ProxyProperty<\/code> Codegen: <a href=\"https:\/\/github.com\/codegen-sh\/codegen\/blob\/590ce812c08d973d8f2c22795ab3e5055cea6b1e\/src\/codegen\/sdk\/_proxy.py#L5\">codegen\/src\/codegen\/sdk\/_proxy.py<\/a><\/p><\/blockquote>\n<p> <\/p>\n<h3><font color=\"#3AC1EF\">\u258d &gt;\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b<\/font><\/h3>\n<p> <\/p>\n<ul>\n<li><a href=\"https:\/\/realpython.com\/python-descriptors\/\">Python Descriptors: An Introduction<\/a><\/li>\n<li><a href=\"https:\/\/deepsource.com\/blog\/demystifying-python-descriptor-protocol\">Demystifying Python\u2019s Descriptor Protocol<\/a><\/li>\n<li><a href=\"https:\/\/docs.python.org\/3\/howto\/descriptor.html\">Descriptor Guide \u2014 Python Wiki<\/a><\/li>\n<li><a href=\"https:\/\/wrapt.readthedocs.io\/en\/latest\/wrappers.html\">Proxies and Wrappers<\/a><\/li>\n<\/ul>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">14. \u041c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u044b<\/font><\/h2>\n<p> \u0412 \u043a\u043e\u043d\u0446\u0435 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0431 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043c\u043e\u0449\u043d\u044b\u0445, \u043d\u043e \u0437\u0430\u0433\u0430\u0434\u043e\u0447\u043d\u044b\u0445 \u0444\u0438\u0447: \u043e <b><font color=\"#3AC1EF\">\u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u0430\u0445<\/font><\/b>.<\/p>\n<pre><code class=\"python\">class MyMetaclass(type):     def __new__(cls, name, bases, namespace):         # \u041c\u0430\u0433\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0434\u0435\u0441\u044c         return super().__new__(cls, name, bases, namespace)  class MyClass(metaclass=MyMetaclass):     pass  obj = MyClass()<\/code><\/pre>\n<p> \u041a\u043b\u0430\u0441\u0441\u044b \u0432 Python \u2014 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u00ab\u0441\u0445\u0435\u043c\u044b\u00bb \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041e\u043d\u0438 \u0442\u043e\u0436\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438! \u0410 \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0439 \u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441. \u0422\u0430\u043a \u0447\u0442\u043e \u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b-\u043a\u043b\u0430\u0441\u0441\u044b? <b><font color=\"#3AC1EF\">\u041c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u044b<\/font><\/b>.<\/p>\n<p> \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, Python \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441 <code>type<\/code>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044d\u0442\u0438 \u0434\u0432\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043a\u043e\u0434\u0430 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0443:<\/p>\n<pre><code class=\"python\"># \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u0431\u044a\u0435\u043a\u0442 MyClass class MyClass:     ... obj = MyClass()  # \u0422\u043e\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u0431\u044a\u0435\u043a\u0442 MyClass obj2 = type(\"MyClass\", (), {})<\/code><\/pre>\n<p> \u0427\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u044d\u0442\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043c \u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 \u0441 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c <code>x<\/code> \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>say_hi<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0430\u043a\u0436\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 <code>object<\/code>.<\/p>\n<pre><code class=\"python\"># type( #     name, #     bases, #     attributes # ) CustomClass = type(     'CustomClass',     (object,),     {'x': 5, 'say_hi': lambda self: 'Hello!'} )  obj = CustomClass() print(obj.x)  # 5 print(obj.say_hi())  # Hello!<\/code><\/pre>\n<p> \u041f\u043e \u0441\u0443\u0442\u0438, \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u044d\u0442\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043e\u0442 \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441, \u0443\u0434\u0432\u0430\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u043a\u0430\u0436\u0434\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 integer \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<pre><code class=\"python\">class DoubleAttrMeta(type):     def __new__(cls, name, bases, namespace):         new_namespace = {}         for key, val in namespace.items():             if isinstance(val, int):                 val *= 2             new_namespace[key] = val         return super().__new__(cls, name, bases, new_namespace)  class MyClass(metaclass=DoubleAttrMeta):     x = 5     y = 10  print(MyClass.x)  # 10 print(MyClass.y)  # 20<\/code><\/pre>\n<p> \u0412\u043e\u0442 \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u0430, \u0437\u0430\u043d\u043e\u0441\u044f\u0449\u0438\u0439 \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0432 registry.<\/p>\n<pre><code class=\"python\"># ===== \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0441 \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u043e\u043c ===== class RegisterMeta(type):     registry = []     def __new__(mcs, name, bases, attrs):         cls = super().__new__(mcs, name, bases, attrs)         mcs.registry.append(cls)         return cls<\/code><\/pre>\n<p> <em>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c<\/em>, \u0447\u0442\u043e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u043c\u043e\u0433\u0443\u0442 \u0440\u0435\u0448\u0430\u0442\u044c \u0442\u0443 \u0436\u0435 \u0441\u0430\u043c\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0447\u0451\u0440\u043d\u043e\u0439 \u043c\u0430\u0433\u0438\u0438 (\u0438 \u043a\u043e\u0434 \u0447\u0430\u0441\u0442\u043e \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0447\u0438\u0449\u0435).<\/p>\n<pre><code class=\"python\"># ===== \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0441 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u043c ===== def register(cls):     registry.append(cls)     return cls  @register class MyClass:     pass<\/code><\/pre>\n<p> \u0418 \u044d\u0442\u043e \u043f\u043e\u0434\u0447\u0451\u0440\u043a\u0438\u0432\u0430\u0435\u0442 \u0441\u0430\u043c\u0443\u044e \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u043e\u0432:<\/p>\n<p> <b><font color=\"#3AC1EF\">\u041f\u043e\u0447\u0442\u0438 \u0432 100% \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0432\u0430\u043c \u043e\u043d\u0438 \u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f.<\/font><\/b><\/p>\n<p> \u0412 \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 99% \u043a\u043e\u0434\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u0430\u0436\u0435 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u0442\u044c \u0442\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u044b\u043b\u0438 \u0431\u044b \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u044b. \u0410 \u0438\u0437 \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u0433\u043e\u0441\u044f 1% \u0432 95% \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0437\u0430\u0434\u0430\u0447\u0443 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432, dunder-\u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p> \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u043e \u0437\u043d\u0430\u043c\u0435\u043d\u0438\u0442\u043e\u0435 \u0438\u0437\u0440\u0435\u0447\u0435\u043d\u0438\u0435 \u043e Python:<\/p>\n<blockquote><p>\u00ab\u041c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u044b \u2014 \u044d\u0442\u043e \u0442\u0430\u043a\u0430\u044f \u0433\u043b\u0443\u0431\u043e\u043a\u0430\u044f \u043c\u0430\u0433\u0438\u044f, \u0447\u0442\u043e 99% \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043e \u043d\u0435\u0439 \u0434\u0443\u043c\u0430\u0442\u044c. \u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u0434\u0430\u0451\u0442\u0435\u0441\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c, \u043d\u0443\u0436\u043d\u044b \u043b\u0438 \u043e\u043d\u0438 \u0432\u0430\u043c, \u0442\u043e \u043e\u043d\u0438 \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u044b\u00bb. \u2014 \u0422\u0438\u043c \u041f\u0438\u0442\u0435\u0440\u0441<\/p><\/blockquote>\n<p> \u041d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u0432\u0445\u043e\u0434\u0438\u0442\u0435 \u0432 \u0442\u043e\u0442 1%, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u0440\u0435\u0448\u0430\u0435\u043c\u0430\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0442\u043e \u043e\u043d\u0438 \u043e\u043a\u0430\u0436\u0443\u0442\u0441\u044f \u043c\u043e\u0449\u043d\u044b\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 Python.<\/p>\n<blockquote><p><b><font color=\"#3AC1EF\">\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u043e\u0432:<\/font><\/b><\/p>\n<ul>\n<li>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u00abABC\u00bb Python \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u044b \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432.<\/li>\n<li>\u0412 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u00abEnum\u00bb Python \u043e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439.<\/li>\n<li>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Django, SQLAlchemy, Pydantic \u0438 Pytest, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u043b\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439 \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u044b.<\/li>\n<\/ul>\n<\/blockquote>\n<p> <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b<\/font><\/h3>\n<p> <\/p>\n<ul>\n<li><a href=\"https:\/\/realpython.com\/python-metaclasses\/\">Python Metaclasses<\/a><\/li>\n<li><a href=\"https:\/\/sentry.io\/answers\/what-are-Python-metaclasses\/\">What are Python Metaclasses?<\/a><\/li>\n<li><a href=\"https:\/\/medium.com\/@miguel.amezola\/demystifying-python-metaclasses-understanding-and-harnessing-the-power-of-custom-class-creation-d7dff7b68de8\">Demystifying Python Metaclasses<\/a><\/li>\n<li><a href=\"https:\/\/s3.dualstack.us-east-2.amazonaws.com\/pythondotorg-assets\/media\/files\/meta-vladimir.txt\">Re: The metaclass saga using Python<\/a><\/li>\n<\/ul>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">\u0417\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435<\/font><\/h2>\n<p> <b><font color=\"#3AC1EF\">\u0412\u043e\u0442, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438 \u0432\u0441\u0451!<\/font><\/b> \u042f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b \u043e 14 \u0441\u0430\u043c\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0438 \u043d\u0435\u0434\u043e\u043e\u0446\u0435\u043d\u0451\u043d\u043d\u044b\u0445 \u0444\u0438\u0447 Python, \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u043c\u043d\u0435 \u0432 \u043c\u043e\u0435\u0439 \u043a\u0430\u0440\u044c\u0435\u0440\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043d\u0430 Python.<\/p>\n<blockquote><p><b><font color=\"#3AC1EF\"><a href=\"https:\/\/t.me\/ruvds_community\">Telegram-\u043a\u0430\u043d\u0430\u043b \u0441\u043e \u0441\u043a\u0438\u0434\u043a\u0430\u043c\u0438, \u0440\u043e\u0437\u044b\u0433\u0440\u044b\u0448\u0430\u043c\u0438 \u043f\u0440\u0438\u0437\u043e\u0432 \u0438 \u043d\u043e\u0432\u043e\u0441\u0442\u044f\u043c\u0438 IT \ud83d\udcbb<\/a><\/font><\/b><\/p><\/blockquote>\n<p><a href=\"https:\/\/ruvds.com\/ru-rub?utm_source=habr&amp;utm_medium=article&amp;utm_campaign=perevod&amp;utm_content=14_interesnyx_fich_python_vozmozhno_ne_sovsem_pythonic\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/yo\/se\/km\/yosekm4h_f7y7oia-ghbbpc0phi.png\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/yo\/se\/km\/yosekm4h_f7y7oia-ghbbpc0phi.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/yo\/se\/km\/yosekm4h_f7y7oia-ghbbpc0phi.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/a><\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/905832\/\"> https:\/\/habr.com\/ru\/articles\/905832\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/companies\/ruvds\/articles\/905832\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/zf\/7s\/e0\/zf7se0iyc_f_541nybtbdqayspu.jpeg\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/zf\/7s\/e0\/zf7se0iyc_f_541nybtbdqayspu.jpeg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/zf\/7s\/e0\/zf7se0iyc_f_541nybtbdqayspu.jpeg 781w\" loading=\"lazy\" decode=\"async\"\/><\/div>\n<p><\/a><br \/> Python \u2014 \u043e\u0434\u0438\u043d \u0438\u0437 <a href=\"https:\/\/survey.stackoverflow.co\/2024\/technology#most-popular-technologies\">\u0441\u0430\u043c\u044b\u0445 \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/a> \u0432 \u043c\u0438\u0440\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u0438\u0437-\u0437\u0430 \u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0435\u0439 \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c <i>\u0447\u0442\u043e-\u0442\u043e<\/i>, \u043e\u043d \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0442\u0430\u043a\u0436\u0435 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043d\u0435\u0434\u043e\u043e\u0446\u0435\u043d\u0451\u043d\u043d\u044b\u0445.<\/p>\n<p> \u0415\u0441\u043b\u0438 \u0437\u0430\u0433\u0443\u0433\u043b\u0438\u0442\u044c <a href=\"https:\/\/www.google.com\/search?q=Top+10+Advanced+Python+Tricks\"><code>\u043b\u0443\u0447\u0448\u0438\u0435 10 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0445 \u0445\u0438\u0442\u0440\u043e\u0441\u0442\u0435\u0439 Python<\/code><\/a>, \u0442\u043e \u0432\u044b \u043d\u0430\u0439\u0434\u0451\u0442\u0435 \u043a\u0443\u0447\u0443 \u043f\u043e\u0441\u0442\u043e\u0432 \u0438\u043b\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u043d\u0430 LinkedIn \u0441 \u043e\u0431\u0437\u043e\u0440\u043e\u043c \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0445 (\u043d\u043e \u0432\u0441\u0451 \u0436\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445) \u0432\u0435\u0449\u0435\u0439 \u0442\u0438\u043f\u0430 <code>\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432<\/code> \u0438\u043b\u0438 <code>\u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439<\/code>.<\/p>\n<p> \u042f \u043f\u0438\u0448\u0443 \u043d\u0430 Python \u0443\u0436\u0435 \u0434\u0432\u0435\u043d\u0430\u0434\u0446\u0430\u0442\u044c \u043b\u0435\u0442, \u0438 \u0437\u0430 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0448\u0451\u043b \u043a\u0443\u0447\u0443 \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445, \u043d\u0435\u0434\u043e\u043e\u0446\u0435\u043d\u0451\u043d\u043d\u044b\u0445, \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0438\u043b\u0438 (\u043a\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u043a\u0442\u043e-\u0442\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c) \u00ab\u043d\u0435-pythonic\u00bb \u0445\u0438\u0442\u0440\u043e\u0441\u0442\u0435\u0439, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 <b><font color=\"#3AC1EF\">\u043f\u043e-\u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443<\/font><\/b> \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0433\u043e \u0434\u043b\u044f Python.<\/p>\n<p> \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437 14 \u043b\u0443\u0447\u0448\u0438\u0445 \u0442\u0430\u043a\u0438\u0445 \u0444\u0438\u0447 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0438\u0445 \u0433\u043b\u0443\u0431\u0436\u0435.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-458247","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/458247","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=458247"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/458247\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=458247"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=458247"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=458247"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}