{"id":336631,"date":"2022-08-05T15:00:53","date_gmt":"2022-08-05T15:00:53","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=336631"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=336631","title":{"rendered":"<span>\u041a\u0430\u043a [\u043d\u0435 \u043d\u0430\u0434\u043e] \u043b\u043e\u043c\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0442\u0438\u043f\u043e\u0432 Python, \u0438\u043b\u0438 \u041a\u0440\u0438\u043c\u0438\u043d\u0430\u043b \u0432 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c<\/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-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/a5b\/863\/4ce\/a5b8634cefac6adeec5205b187132be1.jpg\" width=\"780\" height=\"439\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a5b\/863\/4ce\/a5b8634cefac6adeec5205b187132be1.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p><code>__subclasshook__<\/code> \u2014 \u043e\u0434\u0438\u043d \u0438\u0437 \u043c\u043e\u0438\u0445 \u043b\u044e\u0431\u0438\u043c\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 Python. \u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b (ABC \u2014 Abstract Base Class) \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>__subclasshook__<\/code> \u043c\u043e\u0433\u0443\u0442 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u043e\u043c ABC, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043e\u0431 ABC:<\/p>\n<pre><code class=\"python\">class PalindromicName(ABC):    @classmethod   def __subclasshook__(cls, C):     name = C.__name__.lower()     return name[::-1] == name  class Abba:   ...  class Baba:   ...  >>> isinstance(Abba(), PalindromicName) True >>> isinstance(Baba(), PalindromicName) False<\/code><\/pre>\n<p>\u0421\u0442\u0440\u0430\u043d\u043d\u044b\u0435 \u0432\u0435\u0449\u0438 \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u044d\u0442\u0438\u043c <code>__subclasshook__<\/code>. \u0415\u0449\u0451 \u0432 2019 \u0433\u043e\u0434\u0443 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0435\u0433\u043e \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f <a href=\"https:\/\/www.hillelwayne.com\/negatypes\/\">\u043d\u0435\u043c\u043e\u043d\u043e\u0442\u043e\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432<\/a>, \u0433\u0434\u0435 \u0447\u0442\u043e<em>&#8212;<\/em>\u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f <code>NotIterable<\/code>, \u043a\u043e\u0433\u0434\u0430 <strong>\u043d\u0435<\/strong> \u0438\u043c\u0435\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u0430 <code> __iter__<\/code>. \u0418 \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0443\u0436 \u0434\u044c\u044f\u0432\u043e\u043b\u044c\u0441\u043a\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441 \u044d\u0442\u0438\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0432\u0435\u0434\u044c \u043d\u0438\u0447\u0442\u043e \u0432 Python \u043d\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u043e \u0441 ABC. \u0418 \u044d\u0442\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u043b\u043e \u0443\u0449\u0435\u0440\u0431 \u043a\u043e\u0434\u0443 \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435. <\/p>\n<p>\u041d\u043e \u0432 Python 3.10 <a href=\"https:\/\/www.python.org\/dev\/peps\/pep-0634\/\">\u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 <\/a>\u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c.<\/p>\n<h4>\u041a\u0440\u0430\u0442\u043a\u0438\u0439 \u043e\u0431\u0437\u043e\u0440 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c<\/h4>\n<p>\u0418\u0437 <a href=\"https:\/\/www.python.org\/dev\/peps\/pep-0636\/\">\u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430<\/a>:<\/p>\n<pre><code class=\"python\">match command.split():     case [\"quit\"]:         print(\"Goodbye!\")         quit_game()     case [\"look\"]:         current_room.describe()     case [\"get\", obj]:         character.get(obj, current_room)<\/code><\/pre>\n<p>\u0421\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u044b, \u0441\u043b\u043e\u0432\u0430\u0440\u0438 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b. \u0414\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <code>isinstance(obj, class)<\/code>. \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430:<\/p>\n<ul>\n<li>\n<p><code>obj<\/code> \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f <code>class<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>obj<\/code> \u2014 \u0442\u0440\u0430\u043d\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0434\u0442\u0438\u043f <code>class<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>class<\/code> \u2014 \u044d\u0442\u043e ABC \u0438 \u043e\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 <code>__subclasshook__<\/code>, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0442\u0438\u043f\u0443 <code>obj<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043b\u043e \u043c\u0435\u043d\u044f \u0437\u0430\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b \u043b\u0438 ABC \u00ab\u0443\u0433\u043d\u0430\u0442\u044c\u00bb \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c:<\/p>\n<pre><code class=\"python\">from abc import ABC  class NotIterable(ABC):      @classmethod     def __subclasshook__(cls, C):         return not hasattr(C, \"__iter__\")  def f(x):     match x:         case NotIterable():             print(f\"{x} is not iterable\")         case _:             print(f\"{x} is iterable\")  if __name__ == \"__main__\":     f(10)     f(\"string\")     f([1, 2, 3])<\/code><\/pre>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, Python \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u0442 \u044d\u0442\u0438 \u043f\u0440\u0438\u0434\u0438\u0440\u043a\u0438, \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e?<\/p>\n<pre><code class=\"python\">$ py10 abc.py 10 is not iterable string is iterable [1, 2, 3] is iterable<\/code><\/pre>\n<p>\u041e\u0445\u2026<\/p>\n<h4>\u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0445\u0443\u0436\u0435<\/h4>\n<p>\u0421\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c \u043c\u043e\u0436\u0435\u0442 <a href=\"https:\/\/www.python.org\/dev\/peps\/pep-0636\/#adding-a-ui-matching-objects\">\u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c <\/a>\u043f\u043e\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430:<\/p>\n<pre><code class=\"python\">match event.get():     case Click(position=(x, y)):         handle_click_at(x, y)<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u043b\u0435 \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e <em>\u043f\u043e\u0441\u043b\u0435<\/em> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u0415\u0441\u043b\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c ABC, \u0442\u043e \u043d\u0435 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u00ab\u043b\u044e\u0431\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u0435 <code>foo<\/code>\u00bb:<\/p>\n<pre><code class=\"python\">from abc import ABC from dataclasses import dataclass from math import sqrt  class DistanceMetric(ABC):      @classmethod     def __subclasshook__(cls, C):         return hasattr(C, \"distance\")  def f(x):     match x:         case DistanceMetric(distance=d):             print(d)         case _:             print(f\"{x} is not a point\")  @dataclass class Point2D:     x: float     y: float      @property     def distance(self):         return sqrt(self.x**2 + self.y**2)  @dataclass class Point3D:     x: float     y: float     z: float      @property     def distance(self):         return sqrt(self.x**2 + self.y**2 + self.z**2)  if __name__ == \"__main__\":     f(Point2D(10, 10))     f(Point3D(5, 6, 7))     f([1, 2, 3])<\/code><\/pre>\n<pre><code class=\"python\">14.142135623730951 10.488088481701515 [1, 2, 3] is not a point<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043b\u0443\u0447\u0448\u0435! ABC \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u2014 \u0432\u043e\u043f\u0440\u043e\u0441 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0442\u043e \u0435\u0441\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">def f(x):     match x:         case DistanceMetric(z=3):             print(f\"A point with a z-coordinate of 3\")         case DistanceMetric(z=z):             print(f\"A point with a z-coordinate that's not 3\")         case DistanceMetric():             print(f\"A point without a z-coordinate\")         case _:             print(f\"{x} is not a point\")<\/code><\/pre>\n<h4>\u041a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u044b<\/h4>\n<p>\u0421\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c \u2014 \u044d\u0442\u043e \u0433\u0438\u0431\u043a\u0438\u0439, \u043d\u043e \u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442: \u043e\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0442\u0438\u043f\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u0410 \u0437\u043d\u0430\u0447\u0438\u0442, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 ABC \u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e, \u0447\u0442\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u044d\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438: \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f \u0432 Python \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f; \u0432 99% \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442: \u00ab\u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u044b \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0442\u0438\u043f\u044b, \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u043f\u0440\u043e\u0442\u0438\u0432, \u0447\u0442\u043e\u0431\u044b \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0447\u0442\u043e<em>&#8212;<\/em>\u043d\u0438\u0431\u0443\u0434\u044c \u0443\u043f\u0430\u043b\u043e\u00bb. \u041d\u043e <em>\u0435\u0449\u0451<\/em> \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u0438\u043f\u0430\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0438 <strong>\u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f <\/strong>\u0442\u0438\u043f\u044b \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f.<\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u0438\u043c \u043f\u0440\u0438 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c:<\/p>\n<pre><code class=\"python\">def Not(cls):     class _Not(ABC):         @classmethod         def __subclasshook__(_, C):             return not issubclass(C, cls)     return _Not  def f(x):     match x:         case Not(DistanceMetric)():             print(f\"{x} is not a point\")         case _:             print(f\"{x} is a point\")<\/code><\/pre>\n<p><code>Not<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 <em>\u043d\u043e\u0432\u044b\u0439<\/em> ABC, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e ABC \u0445\u0443\u043a \u043d\u0430 \u00ab\u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u043a\u043b\u0430\u0441\u0441\u0443\u00bb, \u2014 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 ABC:<\/p>\n<pre><code class=\"python\">    case Not(DistanceMetric)():                             ^ SyntaxError: expected ':'<\/code><\/pre>\n<p>\u041e\u0448\u0438\u0431\u043a\u0430! \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u044b \u0434\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c \u0434\u043e \u043f\u0440\u0435\u0434\u0435\u043b\u0430 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c \u0432 ABC. \u041d\u043e \u044d\u0442\u043e \u00ab\u043f\u0440\u043e\u0441\u0442\u043e\u00bb \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430:<\/p>\n<pre><code class=\"diff\">+   n = Not(DistanceMetric)     match x: -       case Not(DistanceMetric)(): +       case n():<\/code><\/pre>\n<pre><code class=\"python\">PlanePoint(x=10, y=10) is a point SpacePoint(x=5, y=6, z=7) is a point [1, 2, 3] is not a point<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c! \u0418 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c <code>And<\/code>:<\/p>\n<pre><code class=\"python\">from abc import ABC from dataclasses import dataclass from collections.abc import Iterable  def Not(cls):     class _Not(ABC):         @classmethod         def __subclasshook__(_, C):             return not issubclass(C, cls)     return _Not  def And(cls1, cls2):     class _And(ABC):         @classmethod         def __subclasshook__(_, C):             return issubclass(C, cls1) and issubclass(C, cls2)     return _And   def f(x):     n = And(Iterable, Not(str))     match x:         case n():             print(f\"{x} is a non-string iterable\")         case str():             print(f\"{x} is a string\")         case _:             print(f\"{x} is a string or not-iterable\")   if __name__ == \"__main__\":     f(\"abc\")     f([1, 2, 3])<\/code><\/pre>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442, <code>\"\"\"\u043a\u0430\u043a \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f\"\"\"<\/code>.<\/p>\n<h4>\u0412\u0441\u0435\u043c \u0437\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h4>\n<p>\u042d\u0442\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043b\u043e \u043c\u0435\u043d\u044f \u0437\u0430\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f: \u00ab\u0427\u0442\u043e, \u0435\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>__subclasshook__<\/code> \u043d\u0435 \u0431\u044b\u043b\u0430 \u0431\u044b \u0447\u0438\u0441\u0442\u043e\u0439?\u00bb \u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c ABC, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 <em>\u043f\u0435\u0440\u0432\u043e\u043c\u0443<\/em>, \u043d\u043e \u043d\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0442\u0438\u043f\u0443?<\/p>\n<pre><code class=\"python\">from abc import ABC  class OneWay(ABC):     seen_classes = set()      @classmethod     def __subclasshook__(cls, C):         print(f\"trying {C}\")         if C in cls.seen_classes:             return False         cls.seen_classes |= {C}         return True  def f(x):     match x:         case OneWay():             print(f\"{x} is a new class\")         case _:             print(f\"we've seen {x}'s class before\")  if __name__ == \"__main__\":     f(\"abc\")     f([1, 2, 3])     f(\"efg\")<\/code><\/pre>\n<p>\u0423\u0432\u044b, \u0432\u0441\u0451 \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u043e:<\/p>\n<pre><code class=\"python\">trying &lt;class 'str'> abc is a new class trying &lt;class 'list'> [1, 2, 3] is a new class efg is a new class<\/code><\/pre>\n<p>\u041f\u043e\u0445\u043e\u0436\u0435, <code>__subclasshook__<\/code> \u043a\u0435\u0448\u0438\u0440\u0443\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430. CPython \u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u0437 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043b\u044e\u0434\u0438 \u043d\u0435 \u0445\u043e\u0442\u044f\u0442 \u0437\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b \u0432 \u044d\u0437\u043e\u0442\u0435\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0443\u0433\u043e\u043b\u043a\u0438 \u044f\u0437\u044b\u043a\u0430. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e <em>\u0438\u043c<\/em>:<\/p>\n<pre><code class=\"python\">class FlipFlop(ABC):     flag = False      @classmethod     def __subclasshook__(cls, _):         cls.flag = not cls.flag         return cls.flag<\/code><\/pre>\n<p>\u041f\u043e\u0440\u0430\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u043c\u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0430\u043c\u0438 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043d\u0435\u043b\u044c\u0437\u044f. \u042d\u0442\u043e\u0442 ABC \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0432\u0441\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0438\u043f\u044b.<\/p>\n<p>\u0410 \u044d\u0442\u043e\u0442 ABC \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0447\u0442\u043e \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u0442\u0438\u043f\u043e\u043c:<\/p>\n<pre><code class=\"python\">class Ask(ABC):     first_class = None      @classmethod     def __subclasshook__(cls, C):         choice = input(f\"hey should I let {C} though [y\/n]  \")         if choice == 'y':             print(\"okay we'll pass em through\")             return True         return False<\/code><\/pre>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u044d\u0442\u0438 \u0434\u0432\u0430 ABC \u0432\u044b\u0448\u0435 \u0432 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c. \u041e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442!<\/p>\n<h3>\u0414\u043e\u043b\u0436\u0435\u043d \u043b\u0438 \u044f \u044d\u0442\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f?<\/h3>\n<p>\u041d\u0435\u0442. \u0412 \u0446\u0435\u043b\u043e\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c \u0441\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0440\u0430\u0437\u0443\u043c\u043d\u043e, \u0438 \u043b\u044e\u0434\u0438 \u043e\u0436\u0438\u0434\u0430\u044e\u0442, \u0447\u0442\u043e \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0443\u043c\u043d\u043e \u0432\u0435\u0441\u0442\u0438 \u0441\u0435\u0431\u044f, \u0430 <code>__subclasshook__<\/code> \u2014 \u044d\u0442\u043e <em>\u043e\u0447\u0435\u043d\u044c<\/em> \u0447\u0451\u0440\u043d\u0430\u044f \u043c\u0430\u0433\u0438\u044f. \u0423\u043b\u043e\u0432\u043a\u0438 \u0441 \u043d\u0438\u043c <em>\u043c\u043e\u0433\u0443\u0442<\/em> \u0438\u043c\u0435\u0442\u044c \u043c\u0435\u0441\u0442\u043e \u0432 \u0442\u0451\u043c\u043d\u043e\u043c \u0441\u0435\u0440\u0434\u0446\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043d\u043e, \u0431\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e, \u043d\u0435 \u0434\u043b\u044f \u043a\u043e\u0434\u0430, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0432\u0430\u0448\u0438 \u043a\u043e\u043b\u043b\u0435\u0433\u0438 \u0431\u0443\u0434\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0434\u0435\u043b\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c. \u0422\u0430\u043a \u0447\u0442\u043e \u0434\u0430, \u043d\u0438\u0447\u0435\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e \u0432\u044b \u043d\u0435 \u0443\u0437\u043d\u0430\u043b\u0438. \u042f \u043f\u0440\u043e\u0441\u0442\u043e \u043b\u044e\u0431\u043b\u044e \u0436\u0443\u0442\u043a\u0438\u0435 \u0448\u0442\u0443\u043a\u0438.<\/p>\n<hr\/>\n<ol>\n<li>\n<p>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 <code>@property<\/code> \u0434\u0435\u043b\u0430\u0435\u0442 <code>distance<\/code> \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430: \u0432\u043c\u0435\u0441\u0442\u043e <code>point.distance()<\/code> \u0441 \u043d\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>point.distance<\/code>, \u0438 <code>__subclasshook__<\/code> \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0449\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u044d\u0442\u0443 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e.<\/p>\n<\/li>\n<\/ol>\n<p>\u0410 \u043c\u044b \u043f\u043e\u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u043a\u0430\u0447\u0430\u0442\u044c \u0432\u0430\u0448\u0438 \u043d\u0430\u0432\u044b\u043a\u0438 \u0438\u043b\u0438 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0441\u0432\u043e\u0438\u0442\u044c \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044e, \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0432 \u043b\u044e\u0431\u043e\u0435 \u0432\u0440\u0435\u043c\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/python-fullstack-web-developer?utm_source=habr&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=coding_fpw_050822&amp;utm_term=conc\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f Fullstack-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 Python<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/data-scientist-pro?utm_source=habr&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=data-science_dspr_050822&amp;utm_term=conc\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f Data Scientist<\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u044b\u0431\u0440\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0443\u044e <a href=\"https:\/\/skillfactory.ru\/catalogue?utm_source=habr&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=sf_allcourses_050822&amp;utm_term=conc\">\u0432\u043e\u0441\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044e<\/a>.<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b16\/dac\/539\/b16dac539a0a09cd1c28951311a610c7.png\" width=\"auto\" height=\"auto\" data-src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b16\/dac\/539\/b16dac539a0a09cd1c28951311a610c7.png\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/company\/skillfactory\/blog\/680744\/\"> https:\/\/habr.com\/ru\/company\/skillfactory\/blog\/680744\/<\/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-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p><code>__subclasshook__<\/code> \u2014 \u043e\u0434\u0438\u043d \u0438\u0437 \u043c\u043e\u0438\u0445 \u043b\u044e\u0431\u0438\u043c\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 Python. \u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b (ABC \u2014 Abstract Base Class) \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>__subclasshook__<\/code> \u043c\u043e\u0433\u0443\u0442 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u043e\u043c ABC, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043e\u0431 ABC:<\/p>\n<pre><code class=\"python\">class PalindromicName(ABC):    @classmethod   def __subclasshook__(cls, C):     name = C.__name__.lower()     return name[::-1] == name  class Abba:   ...  class Baba:   ...  >>> isinstance(Abba(), PalindromicName) True >>> isinstance(Baba(), PalindromicName) False<\/code><\/pre>\n<p>\u0421\u0442\u0440\u0430\u043d\u043d\u044b\u0435 \u0432\u0435\u0449\u0438 \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u044d\u0442\u0438\u043c <code>__subclasshook__<\/code>. \u0415\u0449\u0451 \u0432 2019 \u0433\u043e\u0434\u0443 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0435\u0433\u043e \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f <a href=\"https:\/\/www.hillelwayne.com\/negatypes\/\">\u043d\u0435\u043c\u043e\u043d\u043e\u0442\u043e\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432<\/a>, \u0433\u0434\u0435 \u0447\u0442\u043e<em>&#8212;<\/em>\u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f <code>NotIterable<\/code>, \u043a\u043e\u0433\u0434\u0430 <strong>\u043d\u0435<\/strong> \u0438\u043c\u0435\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u0430 <code> __iter__<\/code>. \u0418 \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0443\u0436 \u0434\u044c\u044f\u0432\u043e\u043b\u044c\u0441\u043a\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441 \u044d\u0442\u0438\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0432\u0435\u0434\u044c \u043d\u0438\u0447\u0442\u043e \u0432 Python \u043d\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u043e \u0441 ABC. \u0418 \u044d\u0442\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u043b\u043e \u0443\u0449\u0435\u0440\u0431 \u043a\u043e\u0434\u0443 \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435. <\/p>\n<p>\u041d\u043e \u0432 Python 3.10 <a href=\"https:\/\/www.python.org\/dev\/peps\/pep-0634\/\">\u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 <\/a>\u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c.<\/p>\n<h4>\u041a\u0440\u0430\u0442\u043a\u0438\u0439 \u043e\u0431\u0437\u043e\u0440 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c<\/h4>\n<p>\u0418\u0437 <a href=\"https:\/\/www.python.org\/dev\/peps\/pep-0636\/\">\u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430<\/a>:<\/p>\n<pre><code class=\"python\">match command.split():     case [\"quit\"]:         print(\"Goodbye!\")         quit_game()     case [\"look\"]:         current_room.describe()     case [\"get\", obj]:         character.get(obj, current_room)<\/code><\/pre>\n<p>\u0421\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u044b, \u0441\u043b\u043e\u0432\u0430\u0440\u0438 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b. \u0414\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <code>isinstance(obj, class)<\/code>. \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430:<\/p>\n<ul>\n<li>\n<p><code>obj<\/code> \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f <code>class<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>obj<\/code> \u2014 \u0442\u0440\u0430\u043d\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0434\u0442\u0438\u043f <code>class<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>class<\/code> \u2014 \u044d\u0442\u043e ABC \u0438 \u043e\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 <code>__subclasshook__<\/code>, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0442\u0438\u043f\u0443 <code>obj<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043b\u043e \u043c\u0435\u043d\u044f \u0437\u0430\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b \u043b\u0438 ABC \u00ab\u0443\u0433\u043d\u0430\u0442\u044c\u00bb \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c:<\/p>\n<pre><code class=\"python\">from abc import ABC  class NotIterable(ABC):      @classmethod     def __subclasshook__(cls, C):         return not hasattr(C, \"__iter__\")  def f(x):     match x:         case NotIterable():             print(f\"{x} is not iterable\")         case _:             print(f\"{x} is iterable\")  if __name__ == \"__main__\":     f(10)     f(\"string\")     f([1, 2, 3])<\/code><\/pre>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, Python \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u0442 \u044d\u0442\u0438 \u043f\u0440\u0438\u0434\u0438\u0440\u043a\u0438, \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e?<\/p>\n<pre><code class=\"python\">$ py10 abc.py 10 is not iterable string is iterable [1, 2, 3] is iterable<\/code><\/pre>\n<p>\u041e\u0445\u2026<\/p>\n<h4>\u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0445\u0443\u0436\u0435<\/h4>\n<p>\u0421\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c \u043c\u043e\u0436\u0435\u0442 <a href=\"https:\/\/www.python.org\/dev\/peps\/pep-0636\/#adding-a-ui-matching-objects\">\u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c <\/a>\u043f\u043e\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430:<\/p>\n<pre><code class=\"python\">match event.get():     case Click(position=(x, y)):         handle_click_at(x, y)<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u043b\u0435 \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e <em>\u043f\u043e\u0441\u043b\u0435<\/em> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u0415\u0441\u043b\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c ABC, \u0442\u043e \u043d\u0435 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u00ab\u043b\u044e\u0431\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u0435 <code>foo<\/code>\u00bb:<\/p>\n<pre><code class=\"python\">from abc import ABC from dataclasses import dataclass from math import sqrt  class DistanceMetric(ABC):      @classmethod     def __subclasshook__(cls, C):         return hasattr(C, \"distance\")  def f(x):     match x:         case DistanceMetric(distance=d):             print(d)         case _:             print(f\"{x} is not a point\")  @dataclass class Point2D:     x: float     y: float      @property     def distance(self):         return sqrt(self.x**2 + self.y**2)  @dataclass class Point3D:     x: float     y: float     z: float      @property     def distance(self):         return sqrt(self.x**2 + self.y**2 + self.z**2)  if __name__ == \"__main__\":     f(Point2D(10, 10))     f(Point3D(5, 6, 7))     f([1, 2, 3])<\/code><\/pre>\n<pre><code class=\"python\">14.142135623730951 10.488088481701515 [1, 2, 3] is not a point<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043b\u0443\u0447\u0448\u0435! ABC \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u2014 \u0432\u043e\u043f\u0440\u043e\u0441 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0442\u043e \u0435\u0441\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">def f(x):     match x:         case DistanceMetric(z=3):             print(f\"A point with a z-coordinate of 3\")         case DistanceMetric(z=z):             print(f\"A point with a z-coordinate that's not 3\")         case DistanceMetric():             print(f\"A point without a z-coordinate\")         case _:             print(f\"{x} is not a point\")<\/code><\/pre>\n<h4>\u041a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u044b<\/h4>\n<p>\u0421\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c \u2014 \u044d\u0442\u043e \u0433\u0438\u0431\u043a\u0438\u0439, \u043d\u043e \u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442: \u043e\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0442\u0438\u043f\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u0410 \u0437\u043d\u0430\u0447\u0438\u0442, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 ABC \u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e, \u0447\u0442\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u044d\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438: \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f \u0432 Python \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f; \u0432 99% \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442: \u00ab\u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u044b \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0442\u0438\u043f\u044b, \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u043f\u0440\u043e\u0442\u0438\u0432, \u0447\u0442\u043e\u0431\u044b \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0447\u0442\u043e<em>&#8212;<\/em>\u043d\u0438\u0431\u0443\u0434\u044c \u0443\u043f\u0430\u043b\u043e\u00bb. \u041d\u043e <em>\u0435\u0449\u0451<\/em> \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u0438\u043f\u0430\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0438 <strong>\u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f <\/strong>\u0442\u0438\u043f\u044b \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f.<\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u0438\u043c \u043f\u0440\u0438 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c:<\/p>\n<pre><code class=\"python\">def Not(cls):     class _Not(ABC):         @classmethod         def __subclasshook__(_, C):             return not issubclass(C, cls)     return _Not  def f(x):     match x:         case Not(DistanceMetric)():             print(f\"{x} is not a point\")         case _:             print(f\"{x} is a point\")<\/code><\/pre>\n<p><code>Not<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 <em>\u043d\u043e\u0432\u044b\u0439<\/em> ABC, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e ABC \u0445\u0443\u043a \u043d\u0430 \u00ab\u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u043a\u043b\u0430\u0441\u0441\u0443\u00bb, \u2014 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 ABC:<\/p>\n<pre><code class=\"python\">    case Not(DistanceMetric)():                             ^ SyntaxError: expected ':'<\/code><\/pre>\n<p>\u041e\u0448\u0438\u0431\u043a\u0430! \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u044b \u0434\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c \u0434\u043e \u043f\u0440\u0435\u0434\u0435\u043b\u0430 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c \u0432 ABC. \u041d\u043e \u044d\u0442\u043e \u00ab\u043f\u0440\u043e\u0441\u0442\u043e\u00bb \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430:<\/p>\n<pre><code class=\"diff\">+   n = Not(DistanceMetric)     match x: -       case Not(DistanceMetric)(): +       case n():<\/code><\/pre>\n<pre><code class=\"python\">PlanePoint(x=10, y=10) is a point SpacePoint(x=5, y=6, z=7) is a point [1, 2, 3] is not a point<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c! \u0418 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c <code>And<\/code>:<\/p>\n<pre><code class=\"python\">from abc import ABC from dataclasses import dataclass from collections.abc import Iterable  def Not(cls):     class _Not(ABC):         @classmethod         def __subclasshook__(_, C):             return not issubclass(C, cls)     return _Not  def And(cls1, cls2):     class _And(ABC):         @classmethod         def __subclasshook__(_, C):             return issubclass(C, cls1) and issubclass(C, cls2)     return _And   def f(x):     n = And(Iterable, Not(str))     match x:         case n():             print(f\"{x} is a non-string iterable\")         case str():             print(f\"{x} is a string\")         case _:             print(f\"{x} is a string or not-iterable\")   if __name__ == \"__main__\":     f(\"abc\")     f([1, 2, 3])<\/code><\/pre>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442, <code>\"\"\"\u043a\u0430\u043a \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f\"\"\"<\/code>.<\/p>\n<h4>\u0412\u0441\u0435\u043c \u0437\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h4>\n<p>\u042d\u0442\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043b\u043e \u043c\u0435\u043d\u044f \u0437\u0430\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f: \u00ab\u0427\u0442\u043e, \u0435\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>__subclasshook__<\/code> \u043d\u0435 \u0431\u044b\u043b\u0430 \u0431\u044b \u0447\u0438\u0441\u0442\u043e\u0439?\u00bb \u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c ABC, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 <em>\u043f\u0435\u0440\u0432\u043e\u043c\u0443<\/em>, \u043d\u043e \u043d\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0442\u0438\u043f\u0443?<\/p>\n<pre><code class=\"python\">from abc import ABC  class OneWay(ABC):     seen_classes = set()      @classmethod     def __subclasshook__(cls, C):         print(f\"trying {C}\")         if C in cls.seen_classes:             return False         cls.seen_classes |= {C}         return True  def f(x):     match x:         case OneWay():             print(f\"{x} is a new class\")         case _:             print(f\"we've seen {x}'s class before\")  if __name__ == \"__main__\":     f(\"abc\")     f([1, 2, 3])     f(\"efg\")<\/code><\/pre>\n<p>\u0423\u0432\u044b, \u0432\u0441\u0451 \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u043e:<\/p>\n<pre><code class=\"python\">trying &lt;class 'str'> abc is a new class trying &lt;class 'list'> [1, 2, 3] is a new class efg is a new class<\/code><\/pre>\n<p>\u041f\u043e\u0445\u043e\u0436\u0435, <code>__subclasshook__<\/code> \u043a\u0435\u0448\u0438\u0440\u0443\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430. CPython \u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u0437 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043b\u044e\u0434\u0438 \u043d\u0435 \u0445\u043e\u0442\u044f\u0442 \u0437\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b \u0432 \u044d\u0437\u043e\u0442\u0435\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0443\u0433\u043e\u043b\u043a\u0438 \u044f\u0437\u044b\u043a\u0430. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e <em>\u0438\u043c<\/em>:<\/p>\n<pre><code class=\"python\">class FlipFlop(ABC):     flag = False      @classmethod     def __subclasshook__(cls, _):         cls.flag = not cls.flag         return cls.flag<\/code><\/pre>\n<p>\u041f\u043e\u0440\u0430\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u043c\u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0430\u043c\u0438 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043d\u0435\u043b\u044c\u0437\u044f. \u042d\u0442\u043e\u0442 ABC \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0432\u0441\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0438\u043f\u044b.<\/p>\n<p>\u0410 \u044d\u0442\u043e\u0442 ABC \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0447\u0442\u043e \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u0442\u0438\u043f\u043e\u043c:<\/p>\n<pre><code class=\"python\">class Ask(ABC):     first_class = None      @classmethod     def __subclasshook__(cls, C):         choice = input(f\"hey should I let {C} though [y\/n]  \")         if choice == 'y':             print(\"okay we'll pass em through\")             return True         return False<\/code><\/pre>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u044d\u0442\u0438 \u0434\u0432\u0430 ABC \u0432\u044b\u0448\u0435 \u0432 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c. \u041e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442!<\/p>\n<h3>\u0414\u043e\u043b\u0436\u0435\u043d \u043b\u0438 \u044f \u044d\u0442\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f?<\/h3>\n<p>\u041d\u0435\u0442. \u0412 \u0446\u0435\u043b\u043e\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c \u0441\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0440\u0430\u0437\u0443\u043c\u043d\u043e, \u0438 \u043b\u044e\u0434\u0438 \u043e\u0436\u0438\u0434\u0430\u044e\u0442, \u0447\u0442\u043e \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0443\u043c\u043d\u043e \u0432\u0435\u0441\u0442\u0438 \u0441\u0435\u0431\u044f, \u0430 <code>__subclasshook__<\/code> \u2014 \u044d\u0442\u043e <em>\u043e\u0447\u0435\u043d\u044c<\/em> \u0447\u0451\u0440\u043d\u0430\u044f \u043c\u0430\u0433\u0438\u044f. \u0423\u043b\u043e\u0432\u043a\u0438 \u0441 \u043d\u0438\u043c <em>\u043c\u043e\u0433\u0443\u0442<\/em> \u0438\u043c\u0435\u0442\u044c \u043c\u0435\u0441\u0442\u043e \u0432 \u0442\u0451\u043c\u043d\u043e\u043c \u0441\u0435\u0440\u0434\u0446\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043d\u043e, \u0431\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e, \u043d\u0435 \u0434\u043b\u044f \u043a\u043e\u0434\u0430, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0432\u0430\u0448\u0438 \u043a\u043e\u043b\u043b\u0435\u0433\u0438 \u0431\u0443\u0434\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0434\u0435\u043b\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c. \u0422\u0430\u043a \u0447\u0442\u043e \u0434\u0430, \u043d\u0438\u0447\u0435\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e \u0432\u044b \u043d\u0435 \u0443\u0437\u043d\u0430\u043b\u0438. \u042f \u043f\u0440\u043e\u0441\u0442\u043e \u043b\u044e\u0431\u043b\u044e \u0436\u0443\u0442\u043a\u0438\u0435 \u0448\u0442\u0443\u043a\u0438.<\/p>\n<hr\/>\n<ol>\n<li>\n<p>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 <code>@property<\/code> \u0434\u0435\u043b\u0430\u0435\u0442 <code>distance<\/code> \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430: \u0432\u043c\u0435\u0441\u0442\u043e <code>point.distance()<\/code> \u0441 \u043d\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>point.distance<\/code>, \u0438 <code>__subclasshook__<\/code> \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0449\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u044d\u0442\u0443 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e.<\/p>\n<\/li>\n<\/ol>\n<p>\u0410 \u043c\u044b \u043f\u043e\u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u043a\u0430\u0447\u0430\u0442\u044c \u0432\u0430\u0448\u0438 \u043d\u0430\u0432\u044b\u043a\u0438 \u0438\u043b\u0438 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0441\u0432\u043e\u0438\u0442\u044c \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044e, \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0432 \u043b\u044e\u0431\u043e\u0435 \u0432\u0440\u0435\u043c\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/python-fullstack-web-developer?utm_source=habr&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=coding_fpw_050822&amp;utm_term=conc\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f Fullstack-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 Python<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/data-scientist-pro?utm_source=habr&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=data-science_dspr_050822&amp;utm_term=conc\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f Data Scientist<\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u044b\u0431\u0440\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0443\u044e <a href=\"https:\/\/skillfactory.ru\/catalogue?utm_source=habr&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=sf_allcourses_050822&amp;utm_term=conc\">\u0432\u043e\u0441\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044e<\/a>.<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/company\/skillfactory\/blog\/680744\/\"> https:\/\/habr.com\/ru\/company\/skillfactory\/blog\/680744\/<\/a><br \/><\/br><\/br><\/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-336631","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/336631","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=336631"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/336631\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=336631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=336631"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=336631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}