{"id":394677,"date":"2024-06-29T11:46:06","date_gmt":"2024-06-29T11:46:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=394677"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=394677","title":{"rendered":"<span>\u042f\u0434\u0440\u043e \u043f\u043b\u0430\u043d\u0435\u0442\u044b Python. \u0418\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0443\u0447\u0435\u0431\u043d\u0438\u043a<\/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\">\n<p>\u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u041c\u0438\u0445\u0430\u0438\u043b \u0415\u043c\u0435\u043b\u044c\u044f\u043d\u043e\u0432, \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b \u043d\u0430 \u00ab\u0425\u0430\u0431\u0440\u0435\u00bb \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e <a href=\"https:\/\/habr.com\/ru\/articles\/697760\/\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u043c \u043f\u0443\u0442\u0435\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u043c \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0435\u0433\u043e Python-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430. \u041f\u043e\u043b\u044c\u0437\u0443\u044f\u0441\u044c \u044d\u0442\u0438\u043c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u043c \u043a\u0430\u043a \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 \u043e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043a\u043d\u0438\u0433\u0438, \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043f\u0435\u0440\u0432\u044b\u0435 \u0447\u0435\u0442\u044b\u0440\u0435 \u0433\u043b\u0430\u0432\u044b \u043c\u0438\u043d\u0438-\u0443\u0447\u0435\u0431\u043d\u0438\u043a\u0430 \u00ab\u042f\u0434\u0440\u043e \u043f\u043b\u0430\u043d\u0435\u0442\u044b Python\u00bb, \u0433\u0434\u0435 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043a\u043e\u0440\u043e\u0442\u043a\u043e, \u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0451\u043c\u043a\u043e \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0443, \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e, \u043a\u0440\u0430\u0441\u043e\u0442\u0443 \u0438 \u0441\u0438\u043b\u0443 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430.<\/p>\n<p>  <\/p>\n<p>\u041e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0443\u0447\u0435\u0431\u043d\u0438\u043a\u0430 \u043b\u0435\u0436\u0438\u0442 \u043d\u0430 <a href=\"https:\/\/github.com\/amaargiru\/pycore\" rel=\"nofollow noopener noreferrer\">GitHub<\/a>, \u0432\u044b \u0432\u043e\u043b\u044c\u043d\u044b \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0433\u043e\u0434\u043d\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e. \u0421\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u0443\u0447\u0435\u0431\u043d\u0438\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 Jupiter Notebook, \u0430 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434, \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u043d\u043e\u0432\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0438\u043b\u0438 \u043f\u0440\u043e\u044f\u0441\u043d\u044f\u044f \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/post_images\/58f\/2c5\/a2c\/58f2c5a2c6142c8bee312e39ec2f4f00.jpg\" alt=\"Core of the planet Python\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/58f\/2c5\/a2c\/58f2c5a2c6142c8bee312e39ec2f4f00.jpg\" data-blurred=\"true\"\/><\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u041f\u043e\u0433\u0440\u0443\u0436\u0430\u044f\u0441\u044c \u0432 Python, \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u0443\u044e \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e <a href=\"https:\/\/docs.python.org\/\" rel=\"nofollow noopener noreferrer\">docs.python.org<\/a>. \u0418\u0437\u0443\u0447\u0438\u0432 \u0435\u0451, \u0445\u043e\u0442\u044f \u0431\u044b \u043f\u043e \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438, \u0438 \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0443\u0433\u043b\u0443\u0431\u043b\u044f\u044f\u0441\u044c \u0432 \u043d\u0443\u0436\u043d\u044b\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044b, \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u00ab\u0445\u0430\u043a\u0438\u00bb, \u00ab\u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f\u00bb \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u0432\u0435\u0449\u0438 \u0443\u0436\u0435 \u0434\u0430\u0432\u043d\u043e \u0440\u0430\u0437\u0436\u0435\u0432\u0430\u043d\u044b, \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0438 \u0438\u043c\u0435\u044e\u0442 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u044f \u0431\u044b \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043b \u0434\u043b\u044f \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 Python \u043d\u0430 \u043f\u043e\u043b\u043d\u0443\u044e \u043a\u0430\u0442\u0443\u0448\u043a\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/leetcode.com\/problemset\/all\/?difficulty=EASY&amp;page=1&amp;status=NOT_STARTED\" rel=\"nofollow noopener noreferrer\">leetcode.com<\/a>. \u0415\u0441\u043b\u0438 \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e \u0443\u0440\u043e\u0432\u043d\u044e \u00abEasy\u00bb, \u0430 \u043f\u043e\u0442\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443 \u043f\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0443 \u00abAcceptance\u00bb, \u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u0432\u0430\u043c\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u043d\u0435\u0442 \u043d\u0435 \u0432\u043e\u043b\u0447\u0438\u0439 \u043e\u0441\u043a\u0430\u043b \u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b, \u0430 \u0432\u0430\u043d\u0438\u043b\u044c\u043d\u044b\u0439 \u0431\u0443\u043a\u0432\u0430\u0440\u044c \u0441 \u043f\u043b\u0430\u0432\u043d\u043e \u043d\u0430\u0440\u0430\u0441\u0442\u0430\u044e\u0449\u0438\u043c \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0435\u043a.<\/p>\n<p>  <\/p>\n<h2 id=\"1-struktury-dannyh\">1. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/post_images\/190\/f06\/61d\/190f0661deb5799fa48e2b28385d98a4.png\" alt=\"Data structures\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/190\/f06\/61d\/190f0661deb5799fa48e2b28385d98a4.png\"\/> <\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 = \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 + \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b (\u0443 \u041d\u0438\u043a\u043b\u0430\u0443\u0441\u0430 \u0412\u0438\u0440\u0442\u0430 \u0434\u0430\u0436\u0435 \u043a\u043d\u0438\u0436\u043a\u0430 \u0442\u0430\u043a\u0430\u044f \u0435\u0441\u0442\u044c). \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u043b\u0430\u0432\u043d\u0435\u043d\u044c\u043a\u043e \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043c\u0435\u0442\u043e\u0434\u0430\u043c \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<p>  <\/p>\n<h3 id=\"spisok-list-a-namebasicdarraya\">\u0421\u043f\u0438\u0441\u043e\u043a (list) <\/h3>\n<p>  <\/p>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u2014 \u0441\u0430\u043c\u0430\u044f \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0430\u044f \u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Python. \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u043a\u0430 \u0442\u043e\u0447\u043d\u043e \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438\u0441\u044c, \u043a\u0430\u043a\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0432 \u0432\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u044c\u043c\u0438\u0442\u0435 \u0441\u043f\u0438\u0441\u043e\u043a, \u0441 \u043d\u0435\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0438\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435.<br \/>  \u0421\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u0443\u044e \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u0443\u044e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432. \u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0435 \u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u2014 \u043c\u0430\u0441\u0441\u0438\u0432 (\u0442\u043e\u0447\u043d\u0435\u0435, vector) \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439, \u0442. \u0435. \u0441\u043f\u0438\u0441\u043e\u043a \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">a = []  # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a  a: list[int] = [10, 20] b: list[int] = [30, 40] a.append(50)  # \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0435\u0446 \u0441\u043f\u0438\u0441\u043a\u0430 b.insert(2, 60)  # \u0412\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0443 print(a, b)  a += b print(f\"Add: {a}\")  a.reverse() b = list(reversed(a))  # reversed() \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440, \u0430 \u043d\u0435 \u0441\u043f\u0438\u0441\u043e\u043a print(f\"Reverse: {a}, {b}\")  b = sorted(a)  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a a.sort()  # \u041c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0438 \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e print(f\"Sort: {a}, {b}\")  s: str = \"A whole string\" list_of_chars: list = list(s) print(list_of_chars) list_of_words: list = s.split() print(list_of_words)  i: int = list_of_chars.index(\"w\")  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0438\u0441\u043a\u043e\u043c\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u043b\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 ValueError print(i) list_of_chars.remove(\"w\")  # \u0423\u0434\u0430\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0432\u043e\u0435 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0438\u0441\u043a\u043e\u043c\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u043b\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 ValueError e = list_of_chars.pop(9)  # \u0423\u0434\u0430\u043b\u044f\u0435\u0442 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0435 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443. pop() (\u0431\u0435\u0437 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430) \u0443\u0434\u0430\u043b\u0438\u0442 \u0438 \u0432\u0435\u0440\u043d\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u043f\u0438\u0441\u043a\u0430 print(list_of_chars, e) a.clear()  # \u041e\u0447\u0438\u0441\u0442\u043a\u0430 \u0441\u043f\u0438\u0441\u043a\u0430<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">[10, 20, 50] [30, 40, 60] Add: [10, 20, 50, 30, 40, 60] Reverse: [60, 40, 30, 50, 20, 10], [10, 20, 50, 30, 40, 60] Sort: [10, 20, 30, 40, 50, 60], [10, 20, 30, 40, 50, 60] ['A', ' ', 'w', 'h', 'o', 'l', 'e', ' ', 's', 't', 'r', 'i', 'n', 'g'] ['A', 'whole', 'string'] 2 ['A', ' ', 'h', 'o', 'l', 'e', ' ', 's', 't', 'i', 'n', 'g'] r<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"kortezh-tuple\">\u041a\u043e\u0440\u0442\u0435\u0436 (tuple)<\/h3>\n<p>  <\/p>\n<p>\u041a\u043e\u0440\u0442\u0435\u0436 \u2014 \u0442\u043e\u0436\u0435 \u0441\u043f\u0438\u0441\u043e\u043a, \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0439 (immutable) \u0438 \u0445\u044d\u0448\u0438\u0440\u0443\u0435\u043c\u044b\u0439 (hashable). \u041a\u043e\u0440\u0442\u0435\u0436, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0442\u0435 \u0436\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0447\u0442\u043e \u0438 \u0441\u043f\u0438\u0441\u043e\u043a, \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u043c\u0435\u0441\u0442\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">a = [2, 3, \"Boson\", \"Higgs\", 1.56e-22] b = (2, 3, \"Boson\", \"Higgs\", 1.56e-22)  print(f\"List: {a.__sizeof__()} bytes\") print(f\"Tuple: {b.__sizeof__()} bytes\")<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">List: 104 bytes Tuple: 64 bytes<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"imenovannyy-kortezh-named-tuple\">\u0418\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0440\u0442\u0435\u0436 (named tuple)<\/h3>\n<p>  <\/p>\n<p>\u0412 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c, \u0438\u043c\u0435\u0435\u0442 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044f. \u0423\u0434\u043e\u0431\u043d\u043e!<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from collections import namedtuple  rectangle = namedtuple('rectangle', 'length width') r = rectangle(length = 1, width = 2)  print(r) print(r.length) print(r.width) print(r._fields)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">rectangle(length=1, width=2) 1 2 ('length', 'width')<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"slovar-dict-a-namebasichashtablea\">\u0421\u043b\u043e\u0432\u0430\u0440\u044c (dict) <\/h3>\n<p>  <\/p>\n<p>\u0421\u043b\u043e\u0432\u0430\u0440\u044c \u2014 \u0432\u0442\u043e\u0440\u0430\u044f \u043f\u043e \u0447\u0430\u0441\u0442\u043e\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Python. dict \u2014 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0430 \u043d\u0435\u043b\u044c\u0437\u044f \u0431\u0440\u0430\u0442\u044c \u043d\u0435\u0445\u0435\u0448\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043f\u0438\u0441\u043e\u043a (\u0442\u0443\u0442-\u0442\u043e \u043d\u0430\u043c \u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043a\u043e\u0440\u0442\u0435\u0436). \u041a\u043b\u044e\u0447\u043e\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442: \u0447\u0438\u0441\u043b\u043e, \u0441\u0442\u0440\u043e\u043a\u0430, datetime \u0438 \u0434\u0430\u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u0422\u0430\u043a\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438\u043c\u0435\u044e\u0442 \u043c\u0435\u0442\u043e\u0434 <strong>__hash__()<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c. \u041f\u043e \u044d\u0442\u043e\u043c\u0443 \u0447\u0438\u0441\u043b\u0443 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0438\u0449\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u043b\u044e\u0447\u0430.<\/p>\n<p>  <\/p>\n<p>\u0421\u043f\u0438\u0441\u043a\u0438, \u0441\u043b\u043e\u0432\u0430\u0440\u0438 \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 (\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0447\u0443\u0442\u044c \u043d\u0438\u0436\u0435) \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b \u0438 \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u043c\u0435\u0442\u043e\u0434\u0430 \u0445\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">d = {}  # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c  d: dict[str, str] = {\"Italy\": \"Pizza\", \"US\": \"Hot-Dog\", \"China\": \"Dim Sum\"}  # \u041d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f  k = [\"Italy\", \"US\", \"China\"] v = [\"Pizza\", \"Hot-Dog\", \"Dim Sum\"] d = dict(zip(k, v))  # \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0438\u0437 \u0434\u0432\u0443\u0445 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 zip  k = d.keys()  # \u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439. \u041e\u0442\u0440\u0430\u0436\u0430\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u0435 v = d.values()  # \u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0422\u043e\u0436\u0435 \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u0435 k_v = d.items()  # \u041a\u043e\u0440\u0442\u0435\u0436\u0438 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u043e\u0436\u0435 \u043e\u0442\u0440\u0430\u0436\u0430\u044e\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u0435  print(d) print(k) print(v) print(k_v)  print(f\"Mapping: {k.mapping['Italy']}\")  d.update({\"China\": \"Dumplings\"})  # \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u041f\u0440\u0438 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0438 \u043a\u043b\u044e\u0447\u0430 \u0441\u0442\u0430\u0440\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043e print(f\"Replace item: {d}\")  c = d[\"China\"]  # \u0427\u0438\u0442\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 print(f\"Read item: {c}\")  try:     v = d.pop(\"Spain\")  # \u0423\u0434\u0430\u043b\u044f\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 KeyError except KeyError:     print(\"Dictionary key doesn't exist\")  # \u041f\u0440\u0438\u043c\u0435\u0440\u044b dict comprehension (\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e comprehension \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u043d\u0438\u0436\u0435) b = {k: v for k, v in d.items() if \"a\" in k}  # \u0412\u0435\u0440\u043d\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u043a\u043b\u044e\u0447\u0430 print(b)  c = {k: v for k, v in d.items() if len(v) >= 7}  # \u0412\u0435\u0440\u043d\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e \u0434\u043b\u0438\u043d\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 print(c)  d.clear() # \u041e\u0447\u0438\u0441\u0442\u043a\u0430 \u0441\u043b\u043e\u0432\u0430\u0440\u044f<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">{'Italy': 'Pizza', 'US': 'Hot-Dog', 'China': 'Dim Sum'} dict_keys(['Italy', 'US', 'China']) dict_values(['Pizza', 'Hot-Dog', 'Dim Sum']) dict_items([('Italy', 'Pizza'), ('US', 'Hot-Dog'), ('China', 'Dim Sum')]) Mapping: Pizza Replace item: {'Italy': 'Pizza', 'US': 'Hot-Dog', 'China': 'Dumplings'} Read item: Dumplings Dictionary key doesn't exist {'Italy': 'Pizza', 'China': 'Dumplings'} {'US': 'Hot-Dog', 'China': 'Dumplings'}<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"reshenie-problemy-vychisleniya-hesha-pri-rabote-so-slovarema-namehashtableproblema\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0445\u0435\u0448\u0430 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u043c<\/h3>\n<p>  <\/p>\n<p>\u041b\u044e\u0431\u0430\u044f \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u043f\u0438\u0442\u043e\u043d\u043e\u0432\u0441\u043a\u0438\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u0434\u043e\u043b\u0436\u043d\u0430 \u0443\u043c\u0435\u0442\u044c \u0440\u0435\u0448\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0445\u0435\u0448\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u0435\u0445\u043d\u0438\u043a\u0438 <strong>open addressing<\/strong> \u0438\u043b\u0438 <strong>chaining<\/strong>. Python <a href=\"https:\/\/stackoverflow.com\/questions\/9010222\/why-can-a-python-dict-have-multiple-keys-with-the-same-hash\" rel=\"nofollow noopener noreferrer\">\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442<\/a> open addressing.<\/p>\n<p>  <\/p>\n<p>\u041d\u043e\u0432\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441 8 \u043f\u0443\u0441\u0442\u044b\u043c\u0438 \u0441\u043b\u043e\u0442\u0430\u043c\u0438.<\/p>\n<p>  <\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443, \u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0435\u043c\u0443 \u043e\u0442 \u0445\u0435\u0448\u0430 \u043a\u043b\u044e\u0447\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">addr = hash(key) &amp; mask,<\/code><\/pre>\n<p>  <\/p>\n<p>\u0433\u0434\u0435<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">mask = PyDictMINSIZE - 1<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u044d\u0442\u043e\u0442 \u0430\u0434\u0440\u0435\u0441 \u0437\u0430\u043d\u044f\u0442, \u0442\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 (\u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 ==) \u0445\u0435\u0448 \u0438 \u043a\u043b\u044e\u0447. \u0415\u0441\u043b\u0438 \u043e\u0431\u0430 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442, \u0442\u043e, \u0437\u043d\u0430\u0447\u0438\u0442, \u0437\u0430\u043f\u0438\u0441\u044c \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442. \u0422\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0437\u043e\u043d\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445 \u0441\u043b\u043e\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u0434\u0435\u0442 \u0432 \u043f\u0441\u0435\u0432\u0434\u043e\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 (\u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0430). \u041d\u043e\u0432\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u043f\u043e \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443.<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043f\u043e\u0438\u0441\u043a \u0441 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 addr \u0438 \u0438\u0434\u0435\u0442 \u043f\u043e \u0442\u043e\u043c\u0443 \u0436\u0435 \u043f\u0441\u0435\u0432\u0434\u043e\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c.<\/p>\n<p>  <\/p>\n<h3 id=\"defaultdict\">Defaultdict<\/h3>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0437 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0442\u0430\u043c \u043d\u0435\u0442, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 KeyError (\u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u043d\u0438\u0436\u0435). Defaultdict \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0447\u0442\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u043a\u0430\u043a \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u044d\u0442\u043e\u0442 \u043a\u043b\u044e\u0447 \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e; \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, defaultdict(int) \u0432\u0435\u0440\u043d\u0435\u0442 0.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from collections import defaultdict  dd = defaultdict(int) print(dd[10])  # \u041f\u0435\u0447\u0430\u0442\u044c int, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d \u043d\u043e\u043b\u044c, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e  dd = {}  # \"\u041e\u0431\u044b\u0447\u043d\u044b\u0439\" \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c # print(dd[10])  # \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 KeyError<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">0<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"schetchik-counter\">\u0421\u0447\u0435\u0442\u0447\u0438\u043a (counter)<\/h3>\n<p>  <\/p>\n<p>\u0421\u0447\u0435\u0442\u0447\u0438\u043a \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0435\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u044b. \u0418\u043d\u043e\u0433\u0434\u0430 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0443\u0445\u043d\u0443\u0442\u044c \u0432 \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0438 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from collections import Counter  shirts_colors = [\"red\", \"white\", \"blue\", \"white\", \"white\", \"black\", \"black\"] c = Counter(shirts_colors) print(c)  c[\"blue\"] += 1 print(f\"After shopping: {c}\") <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Counter({'white': 3, 'black': 2, 'red': 1, 'blue': 1}) After shopping: Counter({'white': 3, 'blue': 2, 'black': 2, 'red': 1})<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b Counter() \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 defaultdict():<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from collections import defaultdict  shirts_colors = [\"red\", \"white\", \"blue\", \"white\", \"white\", \"black\", \"black\"]  d = defaultdict(int) for shirt in shirts_colors:     d[shirt] += 1  print(d)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">defaultdict(&lt;class 'int'>, {'red': 1, 'white': 3, 'blue': 1, 'black': 2})<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"mnozhestvo-set\">\u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e (set)<\/h3>\n<p>  <\/p>\n<p>\u0422\u0440\u0435\u0442\u044c\u044f \u043f\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043f\u0438\u0442\u043e\u043d\u043e\u0432\u0441\u043a\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u043e\u0433\u0434\u0430-\u0442\u043e, \u043a\u043e\u0433\u0434\u0430 Python \u0431\u044b\u043b \u043c\u043e\u043b\u043e\u0434, \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0438 \u0441\u043e\u0431\u043e\u0439 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0434\u0443\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u0438, \u043d\u043e \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0438\u0445 \u0441\u0443\u0434\u044c\u0431\u044b (\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438) \u0441\u0442\u0430\u043b\u0438 \u0440\u0430\u0441\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f. \u041e\u0434\u043d\u0430\u043a\u043e, \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u0430\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">big_cities: set[\"str\"] = {\"New-York\", \"Los Angeles\", \"Ottawa\"} american_cities: set[\"str\"] = {\"Chicago\", \"New-York\", \"Los Angeles\"}  big_cities |= {\"Sydney\"}  # \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (\u0438\u043b\u0438 add()) american_cities |= {\"Salt Lake City\", \"Seattle\"}  # \u0421\u043b\u043e\u0436\u0438\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 (\u0438\u043b\u0438 update())  print(big_cities, american_cities)  union_cities: set[\"str\"] = big_cities | american_cities  # \u0418\u043b\u0438 union() intersected_cities: set[\"str\"] = big_cities &amp; american_cities  # \u0418\u043b\u0438 intersection() dif_cities: set[\"str\"] = big_cities - american_cities  # \u0418\u043b\u0438 difference() symdif_cities: set[\"str\"] = big_cities ^ american_cities  # \u0418\u043b\u0438 symmetric_difference()  issub: bool = big_cities &lt;= union_cities  # \u0418\u043b\u0438 issubset() issuper: bool = american_cities >= dif_cities  # \u0418\u043b\u0438 issuperset()  print(union_cities) print(intersected_cities) print(dif_cities) print(symdif_cities)  print(issub, issuper)  big_cities.add(\"London\")  big_cities.remove(\"Ottawa\")  # \u0423\u0434\u0430\u043b\u044f\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0438\u043b\u0438 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 KeyError big_cities.discard(\"Los Angeles\")  # \u0423\u0434\u0430\u043b\u044f\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0435\u0437 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u044f KeyError big_cities.pop()  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (\u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432 set \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d) \u0438\u043b\u0438 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 KeyError big_cities.clear()  # \u041e\u0447\u0438\u0449\u0430\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">{'New-York', 'Los Angeles', 'Sydney', 'Ottawa'} {'New-York', 'Seattle', 'Chicago', 'Los Angeles', 'Salt Lake City'} {'Ottawa', 'Salt Lake City', 'Chicago', 'New-York', 'Seattle', 'Sydney', 'Los Angeles'} {'New-York', 'Los Angeles'} {'Ottawa', 'Sydney'} {'Seattle', 'Ottawa', 'Chicago', 'Salt Lake City', 'Sydney'} True False<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"immutabelnoe-mnozhestvo-frozen-set\">\u0418\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e (frozen set)<\/h3>\n<p>  <\/p>\n<p>Frozen set \u2014 \u0442\u043e \u0436\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e, \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0435 \u0438 \u0445\u0435\u0448\u0438\u0440\u0443\u0435\u043c\u043e\u0435. \u041d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0438 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u043c, \u043d\u0435 \u043f\u0440\u0430\u0432\u0434\u0430 \u043b\u0438?<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">a = frozenset({\"New-York\", \"Los Angeles\", \"Ottawa\"})<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"massiv-array-bytes-bytearray-a-namearraya\">\u041c\u0430\u0441\u0441\u0438\u0432 (array, bytes, bytearray) <\/h3>\n<p>  <\/p>\n<p>\u042f \u043f\u0435\u0440\u0435\u0448\u0435\u043b \u043d\u0430 Python \u0441 \u044f\u0437\u044b\u043a\u043e\u0432, \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u043d\u044b\u0445 \u043a \u00ab\u0436\u0435\u043b\u0435\u0437\u0443\u00bb (C, C#, \u0434\u0430\u0436\u0435 \u043d\u0430 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435 \u043a\u043e\u0433\u0434\u0430-\u0442\u043e \u043f\u0438\u0441\u0430\u043b \u0437\u0430 \u0434\u0435\u043d\u044c\u0433\u0438 \ud83d\ude42 \u0438 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0434\u0438\u0432\u043b\u044f\u043b\u0441\u044f, \u0447\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u0441\u0451 \u0442\u0430\u043a \u0443\u0434\u043e\u0431\u043d\u043e \u043b\u0435\u0436\u0438\u0442 \u043d\u0430 \u0441\u0432\u043e\u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u0445, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u0434\u043a\u043e. \u041c\u0430\u0441\u0441\u0438\u0432 \u0432 Python \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c\u043e\u0439 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043a\u043e\u0433\u0434\u0430 \u0440\u0435\u0448\u0430\u044e\u0449\u0443\u044e \u0440\u043e\u043b\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0438\u0433\u0440\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0435\u0451 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u041d\u043e, \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0435\u0441\u043b\u0438 \u0432\u044b \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 NumPy \u0438 Pandas (\u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044b \u043d\u0438\u0436\u0435), \u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u2014 \u0432\u0430\u0448\u0435 \u0432\u0441\u0451.<\/p>\n<p>  <\/p>\n<p>\u041c\u0430\u0441\u0441\u0438\u0432 \u0445\u0440\u0430\u043d\u0438\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0441\u043f\u0438\u0441\u043a\u0430, \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043d\u043e\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0438 \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442 \u0443 \u0441\u043f\u0438\u0441\u043a\u0430 \u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u0445 \u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430. \u041c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u043e\u043d\u043a\u0430\u044f \u043e\u0431\u0451\u0440\u0442\u043a\u0430 \u043d\u0430\u0434 \u0421\u0438-\u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438.<\/p>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u0442\u044c array (\u00ab\u043f\u0440\u043e\u0441\u0442\u043e\u00bb \u043c\u0430\u0441\u0441\u0438\u0432), bytes (\u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0439\u0442\u044b, \u043d\u0430\u0441\u043b\u0435\u0434\u0438\u0435 str \u0438\u0437 Python 2) \u0438 bytearray (\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u0439 \u0431\u0430\u0439\u0442\u043e\u0432\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432).<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from array import array  a1 = array(\"l\", [1, 2, 3, -4]) a2 = array(\"b\", b\"1234567890\") b = bytes(a2)  print(a1) print(a2[0]) print(b)  print(a1.index(-4))  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u043b\u0438 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 ValueError<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">array('l', [1, 2, 3, -4]) 49 b'1234567890' 3<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\"># \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435  b1 = bytes([1, 2, 3, 4])  # \u0426\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043e\u0442 0 to 255 b2 = \"The String\".encode('utf-8') b3 = (-1024).to_bytes(4, byteorder='big', signed=True)  # byteorder = \"big\"\/\"little\"\/\"sys.byteorder\", signed = False\/True b4 = bytes.fromhex('FEADCA')  # \u0414\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438 hex-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u044b \u043f\u0440\u043e\u0431\u0435\u043b\u0430\u043c\u0438 b5 = bytes(range(10,30,2))  print(b1, b2, b3, b4, b5)  # \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435  c: list = list(b\"\\xfc\\x00\\x00\\x00\\x00\\x01\") s: str = b'The String'.decode(\"utf-8\") b: int = int.from_bytes(b\"\\xfc\\x00\", byteorder='big', signed=False)  # byteorder = \"big\"\/\"little\"\/\"sys.byteorder\", signed = False\/True s2: str = b\"\\xfc\\x00\\x00\\x00\\x00\\x01\".hex(\" \")  print(c, s, b, s2)  with open(\"1.bin\", \"wb\") as file:  # \u0411\u0430\u0439\u0442\u043e\u0432\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0444\u0430\u0439\u043b     file.write(b1)  with open(\"1.bin\", \"rb\") as file:  # \u0427\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430     b6 = file.read()  print(b6)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">b'\\x01\\x02\\x03\\x04' b'The String' b'\\xff\\xff\\xfc\\x00' b'\\xfe\\xad\\xca' b'\\n\\x0c\\x0e\\x10\\x12\\x14\\x16\\x18\\x1a\\x1c' [252, 0, 0, 0, 0, 1] The String 64512 fc 00 00 00 00 01 b'\\x01\\x02\\x03\\x04'<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"odnosvyaznyy-spisok-a-namebasicslista\">\u041e\u0434\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a <\/h3>\n<p>  <\/p>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Linked_list#Singly_linked_list\" rel=\"nofollow noopener noreferrer\">\u041e\u0434\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a<\/a> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0431\u043e\u0440 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0443\u0437\u043b\u043e\u0432, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0443\u0437\u0435\u043b. \u0412 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0440\u0435\u0434\u043a\u043e, \u043d\u043e \u0435\u0433\u043e \u043b\u044e\u0431\u044f\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e\u0435\u0440\u044b \u043d\u0430 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f\u0445, \u0447\u0442\u043e\u0431\u044b \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442 \u043c\u043e\u0433 \u0431\u043b\u0435\u0441\u043d\u0443\u0442\u044c \u0441\u0432\u043e\u0438\u043c\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0437\u043d\u0430\u043d\u0438\u044f\u043c\u0438. \u0412 Python \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442, \u043c\u043e\u0436\u043d\u043e \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c deque (\u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043b\u0435\u0436\u0438\u0442 \u0434\u0432\u0443\u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a), \u0438\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e.<\/p>\n<p>  <\/p>\n<h3 id=\"dvusvyaznyy-spisok-dequea-namebasicdlista\">\u0414\u0432\u0443\u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a (Deque)<\/h3>\n<p>  <\/p>\n<p>\u0421\u0441\u044b\u043b\u043a\u0438 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0443\u0437\u043b\u0435 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Linked_list#Doubly_linked_list\" rel=\"nofollow noopener noreferrer\">\u0434\u0432\u0443\u0441\u0432\u044f\u0437\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430<\/a> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0438 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0443\u0437\u0435\u043b \u0432 \u0441\u043f\u0438\u0441\u043a\u0435. \u041c\u043e\u0436\u043d\u043e \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c deque, \u0438\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from collections import deque d = deque([1, 2, 3, 4], maxlen=1000)  d.append(5)  # Add element to the right side of the deque d.appendleft(0)  # Add element to the left side of the deque by appending elements from iterable  d.extend([6, 7])  # Extend the right side of the deque d.extendleft([-1, -2])  # Extend the left side of the deque print(d)  a = d.pop()  # Remove and return an element from the right side of the deque. Can raise an IndexError b = d.popleft()  # Remove and return an element from the left side of the deque. Can raise an IndexError print(a, b) print(d)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">deque([-2, -1, 0, 1, 2, 3, 4, 5, 6, 7], maxlen=1000) 7 -2 deque([-1, 0, 1, 2, 3, 4, 5, 6], maxlen=1000)<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"queue\">Queue<\/h3>\n<p>  <\/p>\n<p>Queue \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 FIFO \u0441\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f\u043c\u0438. \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u043f\u0440\u0438 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043e\u0431\u043c\u0435\u043d\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438. \u0422\u0430\u043a\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 LifoQueue \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 LIFO \u0438 PriorityQueue \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0441 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from queue import Queue q = Queue(maxsize=1000)  q.put(\"eat\", block=True, timeout=10) q.put(\"sleep\")  # \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e block=True, timeout=None q.put(\"code\") q.put_nowait(\"repeat\")  # \u042d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442 put(\"repeat\", block=False). \u0415\u0441\u043b\u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u0441\u043b\u043e\u0442 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 queue.Full print(q.queue)  a = q.get(block=True, timeout=10)  # \u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 FIFO b = q.get()  # \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e block=True, timeout=None c = q.get_nowait()  # \u042d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442 get(False) print(a, b, c, q.queue)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">deque(['eat', 'sleep', 'code', 'repeat']) eat sleep code deque(['repeat'])<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"binarnoe-derevo-binary-tree-a-namebasicbinarytreea\">\u0411\u0438\u043d\u0430\u0440\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e (binary tree) <\/h3>\n<p>  <\/p>\n<p>\u0418\u0435\u0440\u0430\u0440\u0445\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u0438\u043c\u0435\u0435\u0442 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u0434\u0432\u0443\u0445 \u043f\u043e\u0442\u043e\u043c\u043a\u043e\u0432. \u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442, \u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u0435\u0440\u0435\u0432\u044c\u044f \u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0435 \u043d\u0438\u0436\u0435.<\/p>\n<p>  <\/p>\n<h3 id=\"kucha-heap\">\u041a\u0443\u0447\u0430 (heap)<\/h3>\n<p>  <\/p>\n<p>\u0411\u0438\u043d\u0430\u0440\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e, \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0435\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043a\u0443\u0447\u0438: \u0435\u0441\u043b\u0438 B \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u0437\u043b\u043e\u043c-\u043f\u043e\u0442\u043e\u043c\u043a\u043e\u043c \u0443\u0437\u043b\u0430 A, \u0442\u043e \u043a\u043b\u044e\u0447(A) \u2265 \u043a\u043b\u044e\u0447(B). \u041a\u0443\u0447\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u044c\u044e \u0441 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u0434\u0432\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u2014 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u043c\u0438\u043d\u0438\u043c\u0443\u043c (\u0438\u043b\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438).<\/p>\n<p>  <\/p>\n<p>\u0412 Python min-\u043a\u0443\u0447\u0430 (\u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043b\u0435\u0436\u0438\u0442 \u0432 \u043a\u043e\u0440\u043d\u0435) \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u0431\u0430\u0437\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f heapq. \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u0430 max-\u043a\u0443\u0447\u0430, \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0432 \u043a\u043e\u0440\u043d\u0435, \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043e\u0432\u0435\u0442\u0430\u043c\u0438 \u0441\u043e <a href=\"https:\/\/stackoverflow.com\/questions\/2501457\/what-do-i-use-for-a-max-heap-implementation-in-python\" rel=\"nofollow noopener noreferrer\">Stackoverflow<\/a>.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import heapq  h = [211, 1, 43, 79, 12, 5, -10, 0] heapq.heapify(h)  # \u041f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0432 \u043a\u0443\u0447\u0443 print(h)  heapq.heappush(h, 2)  # \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 print(h)  m = heapq.heappop(h)  # \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 print(h, m) <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">[-10, 0, 5, 1, 12, 211, 43, 79] [-10, 0, 5, 1, 12, 211, 43, 79, 2] [0, 1, 5, 2, 12, 211, 43, 79] -10<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0431\u0435\u0436\u0438\u043c\u0441\u044f \u043a\u043e\u0440\u043e\u0442\u0435\u043d\u044c\u043a\u043e \u043f\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 Python \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043d\u043e, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043c\u043e\u0433\u0443\u0442 \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435.<\/p>\n<p>  <\/p>\n<h3 id=\"bi-derevo-b-treea-namebtreea\">\u0411\u0438-\u0434\u0435\u0440\u0435\u0432\u043e (B-tree)<\/h3>\n<p>  <\/p>\n<p>\u0421\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u043f\u0430\u043c\u044f\u0442\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0438\u0441\u043a\u043e\u0432\u044b\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c \u0438\u043b\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445); \u043a\u0430\u043a \u0432\u0435\u0442\u0432\u0438, \u0442\u0430\u043a \u0438 \u043b\u0438\u0441\u0442\u044c\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u043f\u0438\u0441\u043a\u0438 (\u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0432 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0445\u043e\u0434 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0440\u0430\u0437\u0431\u043e\u0440\u0430 \u0432 \u041e\u0417\u0423). \u041d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e. \u041b\u0438\u0431\u043e \u2014 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u0432 Python \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 sqlite3, \u044d\u0442\u0430 \u0411\u0414 \u043a\u0430\u043a \u0440\u0430\u0437 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u0431\u0438-\u0434\u0435\u0440\u0435\u0432\u0435.<\/p>\n<p>  <\/p>\n<h3 id=\"krasno-chernoe-derevo-a-namebasicrbtreea\">\u041a\u0440\u0430\u0441\u043d\u043e-\u0447\u0435\u0440\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e <\/h3>\n<p>  <\/p>\n<p>\u0421\u0430\u043c\u043e\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u0443\u044e\u0449\u0435\u0435\u0441\u044f \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u043f\u043e\u0438\u0441\u043a\u0430, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0435\u0435 \u0431\u044b\u0441\u0442\u0440\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438: \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e\u0438\u0441\u043a \u0443\u0437\u043b\u0430. \u0421\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0437\u0430 \u0441\u0447\u0451\u0442 \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0443\u0437\u043b\u0430 \u0434\u0435\u0440\u0435\u0432\u0430 \u2014 \u00ab\u0446\u0432\u0435\u0442\u0430\u00bb. \u042d\u0442\u043e\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0438\u0437 \u0434\u0432\u0443\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u2014 \u00ab\u0447\u0451\u0440\u043d\u044b\u0439\u00bb \u0438\u043b\u0438 \u00ab\u043a\u0440\u0430\u0441\u043d\u044b\u0439\u00bb. \u041b\u0438\u0441\u0442\u043e\u0432\u044b\u0435 \u0443\u0437\u043b\u044b \u041a\u0427 \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438 \u2014 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0443\u0437\u043b\u0435-\u043f\u0440\u0435\u0434\u043a\u0435 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043f\u043e\u0442\u043e\u043c\u043a\u0430. \u041d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e.<br \/>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0447\u0438\u0442\u0430\u043b\u0438 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u0432 FAANG \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0435\u043d\u0442\u043e\u0432 \u00ab\u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043a\u0440\u0443\u0442\u0438\u0442\u044c \u043a\u0440\u0430\u0441\u043d\u043e-\u0447\u0435\u0440\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u043d\u0430 \u0434\u043e\u0441\u043a\u0435\u00bb. \u042d\u0442\u043e \u00ab\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435\u00bb \u0438 \u0435\u0441\u0442\u044c \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0430, \u043f\u043e\u0441\u043b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0434\u0435\u0440\u0435\u0432\u043e \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u043c \u043e\u0431\u044a\u0435\u043c\u043e\u043c \u043a\u043e\u0434\u0430 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f <a href=\"https:\/\/blog.boot.dev\/python\/red-black-tree-python\/\" rel=\"nofollow noopener noreferrer\">\u0437\u0434\u0435\u0441\u044c<\/a> \u0438\u043b\u0438 <a href=\"https:\/\/codereview.stackexchange.com\/questions\/244971\/red-black-tree-implementation-in-python\" rel=\"nofollow noopener noreferrer\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>  <\/p>\n<h3 id=\"avl-derevo-a-namebasicavltreea\">\u0410\u0412\u041b-\u0434\u0435\u0440\u0435\u0432\u043e <\/h3>\n<p>  <\/p>\n<p>\u0412 \u0410\u0412\u041b-\u0434\u0435\u0440\u0435\u0432\u044c\u044f\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435, \u0447\u0435\u043c \u0432 \u043a\u0440\u0430\u0441\u043d\u043e-\u0447\u0435\u0440\u043d\u044b\u0445 \u0434\u0435\u0440\u0435\u0432\u044c\u044f\u0445 (\u043f\u0440\u0438 \u0442\u043e\u043c \u0436\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u043b\u0438\u0441\u0442\u044c\u0435\u0432 \u043a\u0440\u0430\u0441\u043d\u043e-\u0447\u0451\u0440\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0448\u0435 \u0410\u0412\u041b-\u0434\u0435\u0440\u0435\u0432\u0430, \u043d\u043e \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0432 1,388 \u0440\u0430\u0437\u0430). \u041f\u043e\u0438\u0441\u043a \u0436\u0435 \u0432 \u0410\u0412\u041b-\u0434\u0435\u0440\u0435\u0432\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435 (\u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 39 %). \u041d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e.<\/p>\n<p>  <\/p>\n<h3 id=\"prefiksnoe-derevo-a-namebasictriea\">\u041f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e <\/h3>\n<p>  <\/p>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Trie\" rel=\"nofollow noopener noreferrer\">\u041f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e<\/a> (\u0438\u043b\u0438 trie) \u2014 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432, \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0438. \u041d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e.<\/p>\n<p>  <\/p>\n<h3 id=\"tablica-vybora-struktury-dannyh-a-namebasicstructselectiontablea\">\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0432\u044b\u0431\u043e\u0440\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 <\/h3>\n<p>  <\/p>\n<p>\u0412 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u0445\u0443\u0434\u0448\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439.<\/p>\n<p>  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<thead>\n<tr>\n<th>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/th>\n<th>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/th>\n<th>\u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435<\/th>\n<th>\u0418\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f<\/th>\n<th>\u041f\u043e\u0438\u0441\u043a<\/th>\n<th>\u0412\u0441\u0442\u0430\u0432\u043a\u0430<\/th>\n<th>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435<\/th>\n<th>\u041f\u0430\u043c\u044f\u0442\u044c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0430\u0441\u0441\u0438\u0432<\/td>\n<td>list<\/td>\n<td><\/td>\n<td>1<\/td>\n<td>n<\/td>\n<td>n<\/td>\n<td>n<\/td>\n<td>n<\/td>\n<\/tr>\n<tr>\n<td>\u0425\u044d\u0448 \u0442\u0430\u0431\u043b\u0438\u0446\u0430<\/td>\n<td>dict, set<\/td>\n<td><\/td>\n<td><\/td>\n<td>1<br \/>  [n]<\/td>\n<td>1<br \/>  [n]<\/td>\n<td>1<br \/>  [n]<\/td>\n<td>n<\/td>\n<\/tr>\n<tr>\n<td>\u041c\u0430\u0441\u0441\u0438\u0432<\/td>\n<td>array, bytes, bytearray<\/td>\n<td>\u0414\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/td>\n<td>1<\/td>\n<td>n<\/td>\n<td>n<\/td>\n<td>n<\/td>\n<td>n<\/td>\n<\/tr>\n<tr>\n<td>\u041e\u0434\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a<\/td>\n<td> \u2014 (~deque)<\/td>\n<td><\/td>\n<td>n<\/td>\n<td>n<\/td>\n<td>1<\/td>\n<td>1<\/td>\n<td>n<\/td>\n<\/tr>\n<tr>\n<td>\u0414\u0432\u0443\u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a<\/td>\n<td>deque<\/td>\n<td>FIFO, LIFO<\/td>\n<td>n<\/td>\n<td>n<\/td>\n<td>1<\/td>\n<td>1<\/td>\n<td>n<\/td>\n<\/tr>\n<tr>\n<td>\u0411\u0438\u043d\u0430\u0440\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e<\/td>\n<td>&#8212;<\/td>\n<td><\/td>\n<td>logn<br \/>  [n]<\/td>\n<td>logn<br \/>  [n]<\/td>\n<td>logn<br \/>  [n]<\/td>\n<td>logn<br \/>  [n]<\/td>\n<td>n<\/td>\n<\/tr>\n<tr>\n<td>\u041a\u0443\u0447\u0430<\/td>\n<td>heapq<\/td>\n<td>\u041e\u0447\u0435\u0440\u0435\u0434\u044c \u0441 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c<\/td>\n<td><\/td>\n<td>1<br \/>  (find min)<\/td>\n<td>logn<\/td>\n<td>logn<br \/>  (del min)<\/td>\n<td>n<\/td>\n<\/tr>\n<tr>\n<td>B-tree (\u0411\u0438-\u0434\u0435\u0440\u0435\u0432\u043e)<\/td>\n<td>~sqlite<\/td>\n<td>\u0414\u043b\u044f \u043f\u0430\u043c\u044f\u0442\u0438 \u0441 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c<\/td>\n<td>logn<\/td>\n<td>logn<\/td>\n<td>logn<\/td>\n<td>logn<\/td>\n<td>n<\/td>\n<\/tr>\n<tr>\n<td>\u041a\u0427 \u0434\u0435\u0440\u0435\u0432\u043e<\/td>\n<td>&#8212;<\/td>\n<td><\/td>\n<td>logn<\/td>\n<td>logn<\/td>\n<td>logn<\/td>\n<td>logn<\/td>\n<td>n<\/td>\n<\/tr>\n<tr>\n<td>\u0410\u0412\u041b \u0434\u0435\u0440\u0435\u0432\u043e<\/td>\n<td>&#8212;<\/td>\n<td><\/td>\n<td>logn<\/td>\n<td>logn<\/td>\n<td>logn<\/td>\n<td>logn<\/td>\n<td>n<\/td>\n<\/tr>\n<tr>\n<td>\u041f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e<\/td>\n<td>&#8212;<\/td>\n<td>T9,<br \/>  \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c <a href=\"https:\/\/en.wikipedia.org\/wiki\/Aho%E2%80%93Corasick_algorithm\" rel=\"nofollow noopener noreferrer\">\u0410\u0445\u043e\u2013\u041a\u043e\u0440\u0430\u0441\u0438\u043a<\/a>,<br \/>  \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c <a href=\"https:\/\/en.wikipedia.org\/wiki\/Lempel%E2%80%93Ziv%E2%80%93Welch\" rel=\"nofollow noopener noreferrer\">LZW<\/a><\/td>\n<td><\/td>\n<td>key<\/td>\n<td>key<\/td>\n<td>key<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>  <\/p>\n<h3 id=\"perechislenie-enum-intenum\">\u041f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 (Enum, IntEnum)<\/h3>\n<p>  <\/p>\n<p>\u0423\u0434\u043e\u0431\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from enum import Enum, auto import random  class Currency(Enum):     euro = 1     us_dollar = 2     yuan = auto()  local_currency = Currency.us_dollar print(local_currency)  local_currency = Currency[\"us_dollar\"]  # \u041c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 KeyError print(local_currency)  local_currency = Currency(2)  # \u041c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 ValueError print(local_currency)  print(local_currency.name) print(local_currency.value)  list_of_members = list(Currency) member_names    = [e.name for e in Currency] member_values   = [e.value for e in Currency] random_member   = random.choice(list(Currency))  print(list_of_members, \"\\n\",       member_names, \"\\n\",       member_values, \"\\n\",       random_member)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Currency.us_dollar Currency.us_dollar Currency.us_dollar us_dollar 2 [&lt;Currency.euro: 1>, &lt;Currency.us_dollar: 2>, &lt;Currency.yuan: 3>]   ['euro', 'us_dollar', 'yuan']   [1, 2, 3]   Currency.euro<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"celochislennyy-diapazon-range\">\u0426\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0439 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d (range)<\/h3>\n<p>  <\/p>\n<p>range() \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0447\u0438\u0441\u0435\u043b, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0437\u0430\u0434\u0430\u0442\u0447\u0438\u043a \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 \u0434\u043b\u044f \u0446\u0438\u043a\u043b\u0430 for.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\"> r1: range = range(11)  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0447\u0438\u0441\u0435\u043b \u043e\u0442 0 \u0434\u043e 10 r2: range = range(5, 21) # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0447\u0438\u0441\u0435\u043b \u043e\u0442 5 \u0434\u043e 20 r3: range = range(20, 9, -2)  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0447\u0438\u0441\u0435\u043b \u043e\u0442 20 \u0434\u043e 10 \u0441 \u0448\u0430\u0433\u043e\u043c 2  print(\"To exclusive: \", end=\"\") for i in r1:   print(f\"{i} \", end=\"\")  print(\"\\nFrom inclusive to exclusive: \", end=\"\") for i in r2:   print(f\"{i} \", end=\"\")  print(\"\\nFrom inclusive to exclusive with step: \", end=\"\") for i in r3:   print(f\"{i} \", end=\"\")  print(f\"\\nFrom = {r3.start}\") print(f\"To = {r3.stop}\")<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">To exclusive: 0 1 2 3 4 5 6 7 8 9 10  From inclusive to exclusive: 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  From inclusive to exclusive with step: 20 18 16 14 12 10  From = 20 To = 9<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"klassy-dannyh-dataclass\">\u041a\u043b\u0430\u0441\u0441\u044b \u0434\u0430\u043d\u043d\u044b\u0445 (dataclass)<\/h3>\n<p>  <\/p>\n<p>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434\u044b init(), repr() \u0438 eq(). \u041d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u043e\u0432 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u0430\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <a href=\"https:\/\/pypi.org\/project\/attrs\/\" rel=\"nofollow noopener noreferrer\">attrs<\/a>.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from dataclasses import dataclass from decimal import * from datetime import datetime  @dataclass class Transaction:     value: Decimal     issuer: str = \"Default Bank\"     dt: datetime = datetime.now()  t1 = Transaction(value=1000_000, issuer=\"Deutsche Bank\", dt = datetime(2022, 1, 1, 12)) t2 = Transaction(1000)  print(t1) print(t2)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Transaction(value=1000000, issuer='Deutsche Bank', dt=datetime.datetime(2022, 1, 1, 12, 0)) Transaction(value=1000, issuer='Default Bank', dt=datetime.datetime(2022, 9, 6, 17, 50, 36, 162897))<\/code><\/pre>\n<p>  <\/p>\n<p>Dataclass \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u043d \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u043c \u0441 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u043e\u0439 <em>frozen=True<\/em>.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from dataclasses import dataclass  @dataclass(frozen=True) class User:     name: str     account: int<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"binarnaya-zapakovka-struct\">\u0411\u0438\u043d\u0430\u0440\u043d\u0430\u044f \u0437\u0430\u043f\u0430\u043a\u043e\u0432\u043a\u0430 (struct)<\/h3>\n<p>  <\/p>\n<p>\u0417\u0430\u043f\u0430\u043a\u043e\u0432\u043a\u0430 (\u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0430, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f) \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0431\u0430\u0439\u0442\u043e\u0432\u044b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441 \u043f\u0440\u0435\u0434\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u043c\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438\u0445 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0431\u0430\u0439\u0442 \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u043e\u0431\u0430\u0439\u0442\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c Python-\u043e\u0432\u0441\u043a\u0438\u0439 int \u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, short int \u0438\u043b\u0438 long int (<a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D0%B8%D1%81%D1%82%D0%B5%D0%BC%D0%B0_%D1%82%D0%B8%D0%BF%D0%BE%D0%B2_%D0%A1%D0%B8\" rel=\"nofollow noopener noreferrer\">\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0442\u0438\u043f\u043e\u0432 \u044f\u0437\u044b\u043a\u0430 \u0421\u0438<\/a>).<br \/>  \u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 little-endian \u0438 big-endian, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0421\u0438 \u0431\u044b\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u043d\u044b\u043c.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from struct import pack, unpack, iter_unpack  b = pack(\">hhll\", 1, 2, 3, 4) print(b)  t = unpack(\">hhll\", b) print(t)  i = pack(\"ii\", 1, 2) * 5 print(i)  print(list(iter_unpack('ii', i)))<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">b'\\x00\\x01\\x00\\x02\\x00\\x00\\x00\\x03\\x00\\x00\\x00\\x04' (1, 2, 3, 4) b'\\x01\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x02\\x00\\x00\\x00' [(1, 2), (1, 2), (1, 2), (1, 2), (1, 2)]<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"stroka-string\">\u0421\u0442\u0440\u043e\u043a\u0430 (string)<\/h2>\n<p>  <\/p>\n<p>\u0421\u0442\u0440\u043e\u043a\u0438 \u0432 Python 3 \u2014 \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0443 Unicode.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">se: str = \"\"  # \u041f\u0443\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 si: str = str(12345)  # \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 sj: str = \" \".join([\"Follow\", \"the\", \"white\", \"rabbit\"])  # \u0421\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0438\u0437 \u043a\u0443\u0441\u043e\u0447\u043a\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0441\u0435\u043f\u0430\u0440\u0430\u0442\u043e\u0440 print(f\"Joined string: {sj}\")  is_contains: bool = \"rabbit\" in sj  # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438 is_startswith = sj.startswith(\"Foll\") is_endswith = sj.endswith(\"bbit\") print(f\"is_contains = {is_contains}, is_startswith = {is_startswith}, is_endswith = {is_endswith}\")  sr: str  = sj.replace(\"rabbit\", \"sheep\")  # \u0417\u0430\u043c\u0435\u043d\u0430 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438. \u041c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043c\u0435\u043d: sr: str  = sj.replace(\"rabbit\", \"sheep\", times) print(f\"After replace: {sr}\")  i1 = sr.find(\"rabbit\")  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0438\u043b\u0438 -1. \u0415\u0441\u0442\u044c \u0435\u0449\u0435 rfind(), \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0439 \u0438\u0441\u043a\u0430\u0442\u044c \u0441 \u043a\u043e\u043d\u0446\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 i2 = sr.index(\"sheep\")  #  \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0432\u044b\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u0442 ValueError. \u0415\u0441\u0442\u044c \u0435\u0449\u0435 rindex(), \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0439 \u0438\u0441\u043a\u0430\u0442\u044c \u0441 \u043a\u043e\u043d\u0446\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 print(f\"Start index of 'rabbit' is {i1}, start index of 'sheep' is {i2}\")  d = str.maketrans({\"a\" : \"x\", \"b\" : \"y\", \"c\" : \"z\"}) st  = \"abc\".translate(d) print(f\"Translate string: {st}\")  sr = sj[::-1]  # \u0420\u0435\u0432\u0435\u0440\u0441 \u0447\u0435\u0440\u0435\u0437 slice \u0441 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0448\u0430\u0433\u043e\u043c print(f\"Reverse string: {sr}\")<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Joined string: Follow the white rabbit is_contains = True, is_startswith = True, is_endswith = True After replace: Follow the white sheep Start index of 'rabbit' is -1, start index of 'sheep' is 17 Translate string: xyz Reverse string: tibbar etihw eht wolloF<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"datetime\">Datetime<\/h3>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u0442\u0430\u043c\u0438 \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0432 <em>datetime<\/em> \u0435\u0441\u0442\u044c \u0442\u0438\u043f\u044b <em>date<\/em>, <em>time<\/em>, <em>datetime<\/em> \u0438 <em>timedelta<\/em>. \u0412\u0441\u0435 \u043e\u043d\u0438 \u0445\u0435\u0448\u0438\u0440\u0443\u0435\u043c\u044b \u0438 \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b.<\/p>\n<p>  <\/p>\n<h3 id=\"konstruktory\">\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">from datetime import date, time, datetime, timedelta  d: date = date(year=1964, month=9, day=2) t: time  = time(hour=12, minute=30, second=0, microsecond=0, tzinfo=None, fold=0) dt: datetime = datetime(year=1964, month=9, day=2, hour=10, minute=30, second=0) td: timedelta = timedelta(weeks=1, days=1, hours=12, minutes=13, seconds=14)  print (f\"{d}\\n {t}\\n {dt}\\n {td}\")<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">1964-09-02  12:30:00  1964-09-02 10:30:00  8 days, 12:13:14<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"now\">Now<\/h3>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0434\u0430\u0442\u044b \u0438\u043b\u0438 \u0434\u0430\u0442\u044b\/\u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from datetime import date, datetime import pytz import time  d: date  = date.today() dt1: datetime = datetime.today() dt2: datetime = datetime.utcnow() dt3: datetime = datetime.now(pytz.timezone('US\/Pacific'))  t1 = time.time()  # \u042d\u043f\u043e\u0445\u0430 Unix t2 = time.ctime()  print (f\"{d}\\n {dt1}\\n {dt2}\\n {dt3}\\n {t1}\\n {t2}\") <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">2022-09-27  2022-09-27 09:47:02.430474  2022-09-27 04:47:02.430474  2022-09-26 21:47:02.430474-07:00  1664254022.4304743  Tue Sep 27 09:47:02 2022<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"timezone\">Timezone<\/h3>\n<p>  <\/p>\n<p>\u0427\u0430\u0441\u043e\u0432\u044b\u0435 \u043f\u043e\u044f\u0441\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from datetime import date, time, datetime, timedelta, tzinfo from dateutil.tz import UTC, tzlocal, gettz, datetime_exists, resolve_imaginary  tz1: tzinfo = UTC  # \u0427\u0430\u0441\u043e\u0432\u043e\u0439 \u043f\u043e\u044f\u0441 UTC  tz2: tzinfo = tzlocal()  # \u041c\u0435\u0441\u0442\u043d\u044b\u0439 \u0447\u0430\u0441\u043e\u0432\u043e\u0439 \u043f\u043e\u044f\u0441 tz3: tzinfo = gettz()  # \u041c\u0435\u0441\u0442\u043d\u044b\u0439 \u0447\u0430\u0441\u043e\u0432\u043e\u0439 \u043f\u043e\u044f\u0441  tz4: tzinfo = gettz(\"America\/Chicago\")  # \u0418\u043b\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \"Asia\/Kolkata\". \u041f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a: en.wikipedia.org\/wiki\/List_of_tz_database_time_zones  local_dt = datetime.today() utc_dt = local_dt.astimezone(UTC)  # \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f \u043c\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u0447\u0430\u0441\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u044f\u0441\u0430 \u0432 \u0447\u0430\u0441\u043e\u0432\u043e\u0439 \u043f\u043e\u044f\u0441 UTC  print (f\"{tz1}\\n {tz2}\\n {tz3}\\n {tz4}\\n {local_dt}\\n {utc_dt}\")<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">tzutc()  tzlocal()  tzlocal()  tzfile('US\/Central')  2022-09-27 09:19:35.399362  2022-09-27 04:19:35.399362+00:00<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"2-obrabotka-dannyh\">2. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/post_images\/26e\/edf\/fd8\/26eedffd8bf1081be95015e2dccecfc7.png\" alt=\"Data management\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/26e\/edf\/fd8\/26eedffd8bf1081be95015e2dccecfc7.png\"\/> <\/p>\n<p>  <\/p>\n<h3 id=\"srez-slice\">\u0421\u0440\u0435\u0437 (slice)<\/h3>\n<p>  <\/p>\n<p>\u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u0443 \u0447\u0430\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 (\u0438\u043d\u0434\u0435\u043a\u0441\u044b) \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">a:str = \"Pack my box with five dozen liquor jugs\"  start, stop = 8, 21  b:str = a[start:stop]  # \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0442 start \u0434\u043e stop-1 c:str = a[start:]  # \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0442 start \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b d:str = a[:stop]  # \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e stop-1 e:str = a[:]  # \u041f\u043e\u043b\u043d\u0430\u044f \u043a\u043e\u043f\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b  print(b, \"\\n\",       c, \"\\n\",       d, \"\\n\",       e, \"\\n\")<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">box with five   box with five dozen liquor jugs   Pack my box with five   Pack my box with five dozen liquor jugs <\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f start \u0438 stop \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438, \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0437\u043d\u0430\u0447\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u0442\u0441\u0447\u0435\u0442 \u0432\u0435\u0434\u0435\u0442\u0441\u044f \u043e\u0442 \u043a\u043e\u043d\u0446\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u041c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 step, \u0447\u0442\u043e\u0431\u044b \u043d\u0430 \u0432\u044b\u0445\u043e\u0434 \u0441\u0440\u0435\u0437\u0430 \u043f\u043e\u043f\u0430\u043b\u0438 \u043d\u0435 \u0432\u0441\u0435 \u043f\u043e\u0434\u0440\u044f\u0434 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">a:str = \"Step on no pets\"  b:str = a[-4:]  # \u00ab\u0425\u0432\u043e\u0441\u0442\u0438\u043a\u00bb c:str = a[::-1]  # \u0420\u0435\u0432\u0435\u0440\u0441 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 d:str = a[4::-1]  # \u041f\u0435\u0440\u0432\u044b\u0435 \u0447\u0435\u0442\u044b\u0440\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0440\u0435\u0432\u0435\u0440\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u044b e:str = a[::2]  # \u041a\u0430\u0436\u0434\u044b\u0439 \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b  print(b, \"\\n\",       c, \"\\n\",       d, \"\\n\",       e, \"\\n\") <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">pets   step on no petS    petS   Se nn es <\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"sortirovka-sort-sorted\">\u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 (sort, sorted)<\/h3>\n<p>  <\/p>\n<p>\u0412 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0435 \u0432\u0441\u0451 \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0441\u043f\u0440\u044f\u0442\u0430\u043d\u043e \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c (\u043c\u044b \u043d\u0435\u043d\u0430\u0434\u043e\u043b\u0433\u043e \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u044d\u0442\u043e\u0439 \u0442\u0435\u043c\u0435 \u0447\u0443\u0442\u044c \u043d\u0438\u0436\u0435, \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u00ab\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b\u00bb), \u043f\u043e\u043a\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e Python-\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441.<br \/>  \u041d\u0430\u0434\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b sort() \u0438 sorted(), \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 <a href=\"https:\/\/en.wikipedia.org\/wiki\/In-place_algorithm\" rel=\"nofollow noopener noreferrer\">in-place<\/a>, \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">a: list = [5, 2, 3, 1, 4]  b: list = sorted(a) print(a, b)  a.sort() print(a)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">[5, 2, 3, 1, 4] [1, 2, 3, 4, 5] [1, 2, 3, 4, 5]<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 sort(), \u0438 sorted() \u0438\u043c\u0435\u044e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 key \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0435. \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e \u043d\u0440\u0430\u0432\u0443 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0435\u0439 \u0434\u0432\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 (\u0438\u043b\u0438 \u0432\u044b \u043f\u0440\u0438\u0432\u044b\u043a\u043b\u0438 \u043a cmp \u0432 Python 2), \u043f\u0440\u0438\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435\u0441\u044c \u043a functools.cmp_to_key().<\/p>\n<p>  <\/p>\n<pre><code class=\"python\"># \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a  dinos: str = \"Dinosaurs were Big and small\" a = sorted(dinos.split()) print(a)  # \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a  dinos: str = \"Dinosaurs were Big and small\" b = sorted(dinos.split(), key=str.lower) print(b)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">['Big', 'Dinosaurs', 'and', 'small', 'were'] ['and', 'Big', 'Dinosaurs', 'small', 'were']<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u043e\u0447\u0438\u043d\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e key=lambda el: el[1] \u0438\u043b\u0438 \u0434\u0430\u0436\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e key=lambda el: (el[1], el[0]).<\/p>\n<p>  <\/p>\n<h3 id=\"comprehension\">Comprehension<\/h3>\n<p>  <\/p>\n<p>Comprehension, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u043e \u043a\u0430\u043a \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a, \u0442\u043e \u043a\u0430\u043a \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u043e\u0432 (<a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D0%BF%D0%B8%D1%81%D0%BA%D0%BE%D0%B2%D0%BE%D0%B5_%D0%B2%D0%BA%D0%BB%D1%8E%D1%87%D0%B5%D0%BD%D0%B8%D0%B5\" rel=\"nofollow noopener noreferrer\">\u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u044f<\/a>), \u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u2014 \u0441\u043f\u043e\u0441\u043e\u0431 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043f\u0438\u0441\u043a\u043e\u0432 (\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a Python \u2014 \u0435\u0449\u0435 \u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439, \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432).<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a, \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0442 \u043a\u0430\u043a\u043e\u043c\u0443-\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0443\u0441\u043b\u043e\u0432\u0438\u044e, \u0438\u043b\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u044b\u0435 \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u043e \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c, \u0442\u043e comprehension \u2014 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0435\u043d\u0442 \u043d\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u2116 1.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\"># \u041f\u0440\u0438\u043c\u0435\u0440\u044b Comprehension  a = [i+1 for i in range(10)]  # list b  = {i for i in range(10) if i > 5}  # set c = (2*i+5 for i in range(10))  # iter d = {i: i**2 for i in range(10)}  # dict  print(a,\"\\n\", b, \"\\n\", list(c), \"\\n\", d)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]   {8, 9, 6, 7}   [5, 7, 9, 11, 13, 15, 17, 19, 21, 23]   {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81}<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0443\u0442 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043d\u0435 \u043f\u0435\u0440\u0435\u0433\u043d\u0443\u0442\u044c \u043f\u0430\u043b\u043a\u0443. \u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c comprehension \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0438 \u043d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0439, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0441\u0442\u043e\u0438\u0442 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0432 \u00ab\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439\u00bb \u0446\u0438\u043a\u043b \u0438\u043b\u0438 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c. Comprehension \u0441\u043e\u0431\u043b\u0430\u0437\u043d\u044f\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u00ab\u043e\u0434\u043d\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u0438\u043a\u0430\u043c\u0438\u00bb \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043d\u043e \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e 90 % \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0447\u0438\u0442\u0430\u0435\u0442 \u043a\u043e\u0434, \u0438 \u0442\u043e\u043b\u044c\u043a\u043e 10 % \u043f\u0438\u0448\u0435\u0442, \u0442\u0430\u043a \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043b\u043e\u0445\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c, \u0432\u044b \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u0442\u0435 \u0436\u0438\u0437\u043d\u044c \u0438 \u0441\u0435\u0431\u0435, \u0438 \u0441\u0432\u043e\u0438 \u043a\u043e\u043b\u043b\u0435\u0433\u0430\u043c.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u0442\u044c \u0431\u043e\u043b\u0435\u0435-\u043c\u0435\u043d\u0435\u0435 <a href=\"https:\/\/leetcode.com\/problems\/flipping-an-image\/discuss\/2378360\/python-1-liner-988-speed-97-mem\" rel=\"nofollow noopener noreferrer\">\u0443\u0434\u0430\u0447\u043d\u044b\u0435<\/a> \u00ab\u043e\u0434\u043d\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u0438\u043a\u0438\u00bb, \u0435\u0441\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0435, \u043d\u043e <a href=\"https:\/\/leetcode.com\/problems\/reverse-string-ii\/discuss\/2281269\/python-fast-beats-984-and-short-almost-1-line-solution-with-python-38-features-pep572\" rel=\"nofollow noopener noreferrer\">\u043f\u043b\u043e\u0445\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0435<\/a>, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0441\u043f\u043e\u0440\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430 (\u044d\u0442\u043e \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0440\u0435\u0448\u0435\u043d\u043d\u044b\u0435 \u043c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u043a\u0438 \u043d\u0430 leetcode), \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c comprehension \u0432 \u043c\u0435\u0440\u0443; \u043b\u0443\u0447\u0448\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0447\u0435\u043c \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439, \u043d\u043e \u043e\u0431\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f\u043c\u0438 (\u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u043e\u0441\u043e\u0431\u044b\u0445 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 \u043a \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0441\u0430\u043c\u043e \u0441\u043e\u0431\u043e\u0439).<\/p>\n<p>  <\/p>\n<p>\u0415\u0449\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e list comprehension:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\"># new_list = [expression for member in iterable (if conditional)]  fruits: list = [\"Lemon\", \"Apple\", \"Banana\", \"Kiwi\", \"Watermelon\", \"Pear\"]  e_fruits = [fruit for fruit in fruits if \"e\" in fruit] #                                     \u261d \u0443\u0441\u043b\u043e\u0432\u0438\u0435 print(e_fruits)  upper_fruits = [fruit.upper() for fruit in fruits] #                     \u261d \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 print(upper_fruits)  # \u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0430 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0439 \u0434\u043b\u0438\u043d\u044b chunk_len = 2 chunk_fruits = [fruits[i:i + chunk_len] for i in range(0, len(fruits), chunk_len)] print(chunk_fruits) <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">['Lemon', 'Apple', 'Watermelon', 'Pear'] ['LEMON', 'APPLE', 'BANANA', 'KIWI', 'WATERMELON', 'PEAR'] [['Lemon', 'Apple'], ['Banana', 'Kiwi'], ['Watermelon', 'Pear']]<\/code><\/pre>\n<p>  <\/p>\n<p>Dict comprehension, \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\"># new_dict = {expression for member in iterable (if conditional)}  d: dict = {\"Italy\": \"Pizza\", \"US\": \"Hot-Dog\", \"China\": \"Dim Sum\", \"South Korea\": \"Kimchi\"} print(d)  a: dict = {k: v for k, v in d.items() if \"i\" in v}  # \u0412\u0435\u0440\u043d\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e print(a)  b: dict = {k: v for k, v in d.items() if \"i\" in k}  # \u0412\u0435\u0440\u043d\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e \u043a\u043b\u044e\u0447\u0443 print(b)  c: dict = {k: v for k, v in d.items() if len(v) >= 7}  # \u0412\u0435\u0440\u043d\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e \u0434\u043b\u0438\u043d\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 print(c)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">{'Italy': 'Pizza', 'US': 'Hot-Dog', 'China': 'Dim Sum', 'South Korea': 'Kimchi'} {'Italy': 'Pizza', 'China': 'Dim Sum', 'South Korea': 'Kimchi'} {'China': 'Dim Sum'} {'US': 'Hot-Dog', 'China': 'Dim Sum'}<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c\u0441\u044f \u0441 set comprehension. \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435, \u0447\u0442\u043e set \u00ab\u043f\u0435\u0440\u0435\u0432\u0430\u0440\u0438\u0432\u0430\u0435\u0442\u00bb \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0442\u043e, \u043d\u0430 \u0447\u0442\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043b\u0438.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0442\u0430\u043a\u0436\u0435 \u043e\u0441\u0432\u043e\u0438\u0442\u044c nested (\u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439) comprehension, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0432\u0438\u0434\u0430 [[func(y) for y in x] for x in n]. \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043b\u0430\u0432\u043d\u043e \u043d\u0430\u0440\u0430\u0441\u0442\u0430\u0435\u0442 \u0431\u043b\u0438\u0436\u0435 \u043a \u043f\u0440\u0430\u0432\u043e\u043c\u0443 \u043d\u0438\u0436\u043d\u0435\u043c\u0443 \u0443\u0433\u043b\u0443 (\u0435\u0441\u043b\u0438 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0435\u0441\u0442\u044c \u0447\u0443\u0442\u044c \u043d\u0438\u0436\u0435, \u0432 \u043a\u043e\u0434\u0435, \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 matplotlib). <\/p>\n<p>  <\/p>\n<h3 id=\"operacii-nad-strokami-lower-upper-capitalize-i-title\">\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438. lower(), upper(), capitalize() \u0438 title()<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">s: str = \"camelCase string\"  print(s.lower()) print(s.upper()) print(s.capitalize()) print(s.title())<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">camelcase string CAMELCASE STRING Camelcase string Camelcase String<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"strip\">strip()<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">s: str = \"  ~~##A big blahblahblah##~~  \"  s = s.strip()  # Strips all whitespace characters from both ends print(s)  s = s.strip(\"~#\")  # Strips all passed characters from both ends print(s)  s = s.lstrip(\" A\")  # Strips all passed characters from left end print(s)  s = s.rstrip(\"habl\")  # Strips all passed characters from right end print(s) <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">~~##A big blahblahblah##~~ A big blahblahblah big blahblahblah big <\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"split\">split()<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">s1: str = \"Follow the white rabbit, Neo\"  c1 = s1.split()  # Splits on one or more whitespace characters print(c1)  c2 = s1.split(sep=\", \", maxsplit=1)  # Splits on \"sep\" str at most \"maxsplit\" times print(c2)  s2: str = \"Beware the Jabberwock, my son!\\n The jaws that bite, the claws that catch!\"  c3 = s2.splitlines(keepends=False)  # On [\\n\\r\\f\\v\\x1c-\\x1e\\x85\\u2028\\u2029] and \\r\\n. print(c3)  # split() vs rsplit()  c4 = s2.split(maxsplit=2) c5 = s2.rsplit(maxsplit=2)  print(c4, c5)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">['Follow', 'the', 'white', 'rabbit,', 'Neo'] ['Follow the white rabbit', 'Neo'] ['Beware the Jabberwock, my son!', ' The jaws that bite, the claws that catch!'] ['Beware', 'the', 'Jabberwock, my son!\\n The jaws that bite, the claws that catch!'] ['Beware the Jabberwock, my son!\\n The jaws that bite, the claws', 'that', 'catch!']<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"ord-chr\">ord(), chr()<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">s1: str = \"abcABC!\"  for ch in s1:     print(f\"{ch} -> {ord(ch)}\")  # Returns an integer representing the Unicode character  nums = [72, 101, 108, 108, 111, 33]  for num in nums:     print(f\"{num} -> {chr(num)}\")<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">a -> 97 b -> 98 c -> 99 A -> 65 B -> 66 C -> 67 ! -> 33 72 -> H 101 -> e 108 -> l 108 -> l 111 -> o 33 -> !<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"regex\">Regex<\/h3>\n<p>  <\/p>\n<p>\u0420\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u2014 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0437\u043d\u0430\u043d\u0438\u0439, \u0438 \u0432\u0435\u0441\u044c\u043c\u0430-\u0432\u0435\u0441\u044c\u043c\u0430 \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c. \u0422\u0443\u0442, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u0441\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0434\u043b\u044f \u0431\u043e\u0440\u043e\u0434\u0430\u0442\u043e\u0439 \u0448\u0443\u0442\u043a\u0438 \u043f\u0440\u043e \u0442\u043e, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u0441\u0432\u043e\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u2014 \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u0432\u0430\u0441 \u0434\u0432\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. <\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u0438 \u043f\u043e\u0445\u043e\u0436\u0438 \u043d\u0430 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0432 \u0432\u043e\u0434\u0443 \u043d\u0430 \u043f\u043b\u044f\u0436\u0435 \u043e\u0441\u0442\u0440\u043e\u0432\u0430 \u0413\u0443\u0430\u043c \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u041c\u0430\u0440\u0438\u0430\u043d\u0441\u043a\u043e\u0439 \u0432\u043f\u0430\u0434\u0438\u043d\u044b \u2014 \u0434\u0430\u0436\u0435 \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0434\u0443\u043c\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u043b\u0438\u0441\u044c <em>\u0440\u0435\u0430\u043b\u044c\u043d\u043e<\/em> \u0433\u043b\u0443\u0431\u043e\u043a\u043e, \u0442\u043e, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0432\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0432\u0438\u0434\u0438\u0442\u0435 \u0432\u043f\u0435\u0440\u0435\u0434\u0438\u043b\u0435\u0436\u0430\u0449\u0435\u0439 \u0431\u0435\u0437\u0434\u043d\u044b. \u041d\u043e \u2014 \u0437\u043d\u0430\u0442\u044c \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0445\u043e\u0442\u044f \u0431\u044b \u043d\u0430 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0446\u0435\u043b\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0437\u0430\u0434\u0430\u0447, \u0430 \u0442\u043e, \u0447\u0442\u043e \u0432\u0451\u0440\u0442\u043a\u0438\u0435 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u0438 \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043a \u0432\u0430\u043c \u0441\u0432\u043e\u0438\u043c\u0438, \u043a\u0445\u043c\u2026 \u043d\u043e\u0432\u044b\u043c\u0438 \u0433\u0440\u0430\u043d\u044f\u043c\u0438, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c, \u043f\u0435\u0440\u0435\u0432\u0430\u0440\u0438\u0442\u044c \u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u044c. <\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 <a href=\"https:\/\/habr.com\/ru\/post\/349860\/\">\u0437\u0434\u0435\u0441\u044c<\/a> \u0435\u0441\u0442\u044c \u0433\u0440\u0430\u043c\u043e\u0442\u043d\u043e\u0435 \u0438 \u043c\u0435\u0442\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u0434\u0435\u0440\u0436\u0430\u043d\u043d\u043e\u0435 \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0442\u0435\u043c\u0443, \u043f\u043e\u043a\u0430 \u0436\u0435 \u043e\u043a\u0438\u043d\u0435\u043c \u0432\u0437\u0433\u043b\u044f\u0434\u043e\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import re  s1: str = \"123 abc ABC 456\"  m1 = re.search(\"[aA]\", s1)  # \u0418\u0449\u0435\u0442 \u043f\u0435\u0440\u0432\u043e\u0435 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430, \u043f\u0440\u0438 \u043d\u0435\u0443\u0434\u0430\u0447\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 None print(m1, m1.group(0))  m2 = re.fullmatch(\"[aA]\", s1)  # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u043e\u0434 \u0448\u0430\u0431\u043b\u043e\u043d print(m2)  c1: list = re.findall(\"[aA]\", s1)  # \u041d\u0430\u0439\u0442\u0438 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 \u0432\u0441\u0435 \u043d\u0435\u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u044b print(c1)  def replacer(s):     return chr(ord(s[0]) + 1)  # \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0438\u0437 \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0430  s2 = re.sub(\"\\w\", replacer, s1)  # \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432\u043c\u0435\u0441\u0442\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430 print(s2)  c2 = re.split(\"\\d\", s1) print(c2)  iter = re.finditer(\"\\D\", s1)  # \u0418\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u043e \u043d\u0435\u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0449\u0438\u043c\u0441\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c  for ch in iter:     print(ch.group(0), end= \"\")<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">&lt;re.Match object; span=(4, 5), match='a'> a None ['a', 'A'] 234 bcd BCD 567 ['', '', '', ' abc ABC ', '', '', '']  abc ABC <\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"match-object\">Match Object<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">import re  m3 = re.match(r\"(\\w+) (\\w+)\", \"John Connor, leader of the Resistance\")  s3: str = m3.group(0)  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 s4: str = m3.group(1)  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0447\u0430\u0441\u0442\u044c \u0432 \u043f\u0435\u0440\u0432\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 t1: tuple = m3.groups() start: int = m3.start()  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f end: int = m3.end()  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f t2: tuple[int, int] = m3.span()  # \u041a\u043e\u0440\u0442\u0435\u0436 (start, end)  print (f\"{s3}\\n {s4}\\n {t1}\\n {start}\\n {end}\\n {t2}\\n\")<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">John Connor  John  ('John', 'Connor')  0  11  (0, 11)<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"sozdanie-peremennyh-datetime\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 datetime<\/h3>\n<p>  <\/p>\n<p>Python \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Unix Epoch: &#171;1970-01-01 00:00 UTC&#187;<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from datetime import datetime from dateutil.tz import tzlocal  dt1: datetime = datetime.fromisoformat(\"2021-10-04 00:05:23.555+00:00\")  # \u041c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c ValueError dt2: datetime = datetime.strptime(\"21\/10\/04 17:30\", \"%d\/%m\/%y %H:%M\")   # \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u044b - https:\/\/docs.python.org\/3\/library\/datetime.html#strftime-and-strptime-format-codes dt3: datetime = datetime.fromordinal(100_000)  # 100000-\u0439 \u0434\u0435\u043d\u044c \u043e\u0442 1.1.0001 dt4: datetime = datetime.fromtimestamp(20_000_000.01)  # \u0412\u0440\u0435\u043c\u044f \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445 \u0441 \u043d\u0430\u0447\u0430\u043b\u0430 Unix Epoch  tz = tzlocal() dt5: datetime = datetime.fromtimestamp(20_000_000.01, tz)  # \u0421 \u0443\u0447\u0435\u0442\u043e\u043c \u0447\u0430\u0441\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u044f\u0441\u0430  print (f\"{dt1}\\n {dt2}\\n {dt3}\\n {dt4}\\n {dt5}\")<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">2021-10-04 00:05:23.555000+00:00  2004-10-21 17:30:00  0274-10-16 00:00:00  1970-08-20 16:33:20.010000  1970-08-20 16:33:20.010000+05:00<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"preobrazovanie-peremennyh-datetime\">\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 datetime<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">from datetime import datetime  dt1: datetime = datetime.today()  s1: str = dt1.isoformat() s2: str = dt1.strftime(\"%d\/%m\/%y %H:%M\")  # https:\/\/docs.python.org\/3\/library\/datetime.html#strftime-and-strptime-format-codes i: int = dt1.toordinal() a: float = dt1.timestamp()  # \u0421\u0435\u043a\u0443\u043d\u0434\u044b \u0441 \u043d\u0430\u0447\u0430\u043b\u0430 Unix Epoch  print (f\"{dt1}\\n {s1}\\n {s2}\\n {i}\\n {a}\")<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">2022-09-06 17:50:38.041159  2022-09-06T17:50:38.041159  06\/09\/22 17:50  738404  1662468638.041159<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"arifmetika-datetime\">\u0410\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0430 datetime<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">from datetime import date, time, datetime, timedelta from dateutil.tz import UTC, tzlocal, gettz, datetime_exists, resolve_imaginary  d: date  = date.today() dt1: datetime = datetime.today() dt2: datetime = datetime(year=1981, month=12, day=2) td1: timedelta = timedelta(days=5) td2: timedelta = timedelta(days=1)  d = d + td1  # date = date \u00b1 timedelta dt3 = dt1 - td1  # datetime = datetime \u00b1 timedelta  td3 = dt1 - dt2  # timedelta = datetime - datetime  td4 = 10 * td1  # timedelta = const * timedelta c: float = td1\/td2  # timedelta\/timedelta  print (f\"{d}\\n {dt3}\\n {td3}\\n {td4}\\n {c}\")<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">2022-09-11  2022-09-01 17:50:38.132916  14888 days, 17:50:38.132916  50 days, 0:00:00  5.0<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"bisect-i-binarnyy-poisk\">bisect \u0438 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a<\/h3>\n<p>  <\/p>\n<p>\u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 (\u0441\u043c. \u0440\u0430\u0437\u0434\u0435\u043b \u00ab\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b\u00bb), \u043d\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0438\u0441\u043a.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import bisect  a: list[int] = [12, 6, 8, 19, 1, 33]  a.sort() print(f\"Sorted: {a}\")  print(bisect.bisect(a, 20))  # \u041d\u0430\u0439\u0442\u0438 \u0438\u043d\u0434\u0435\u043a\u0441 \u0434\u043b\u044f \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0441\u0442\u0430\u0432\u043a\u0438  bisect.insort(a, 15)  # \u0412\u0441\u0442\u0430\u0432\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c print(a)  # \u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a  def binary_search(a, x, lo=0, hi=None):     if hi is None:         hi = len(a)      pos = bisect.bisect_left(a, x, lo, hi)     return pos if pos != hi and a[pos] == x else -1  print(binary_search(a, 15))<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Sorted: [1, 6, 8, 12, 19, 33] 5 [1, 6, 8, 12, 15, 19, 33] 4<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"funkcionalnoe-programmirovanie-map-filter-reduce-partial\">\u0424\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (Map, Filter, Reduce, Partial)<\/h3>\n<p>  <\/p>\n<p>\u041d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0438 \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u0432\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0435\u0441\u044c \u043a \u043c\u0435\u0441\u0442\u0443 \u0438 \u043d\u0435 \u043c\u0435\u0441\u0442\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u0451\u043c\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u043e\u0434 \u00ab\u0432\u043e\u0438\u0441\u0442\u0438\u043d\u0443 \u043a\u0440\u0443\u0442\u044b\u043c\u00bb, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0446\u0438\u0442\u0438\u0440\u0443\u044e \u0432\u0430\u043c \u0414\u0436\u043e\u044d\u043b\u044f \u0413\u0440\u0430\u0441\u0430, \u0430\u0432\u0442\u043e\u0440\u0430 \u043a\u043d\u0438\u0433\u0438 \u00abData Science: \u041d\u0430\u0443\u043a\u0430 \u043e \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043d\u0443\u043b\u044f\u00bb: \u00ab\u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0438\u0437\u0434\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0439 \u043a\u043d\u0438\u0433\u0438 \u0431\u044b\u043b\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 partial, map, reduce \u0438 filter \u044f\u0437\u044b\u043a\u0430 Python. \u041d\u0430 \u0441\u0432\u043e\u0435\u043c \u043f\u0443\u0442\u0438 \u043a \u043f\u0440\u043e\u0441\u0432\u0435\u0442\u043b\u0435\u043d\u0438\u044e \u044f \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u044d\u0442\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043b\u0443\u0447\u0448\u0435 \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c, \u0438 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043a\u043d\u0438\u0433\u0435 \u0431\u044b\u043b\u043e \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a, \u0446\u0438\u043a\u043b\u0430\u043c\u0438 \u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438, \u0431\u043e\u043b\u0435\u0435 Python&#8217;\u043e\u0432\u0441\u043a\u0438\u043c\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c\u0438\u00bb. \u0422\u0430\u043a\u0438\u0435 \u0434\u0435\u043b\u0430\u2026 <\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import functools  # \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0432\u0441\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 iter1 = map(lambda x: x + 1, range(10)) print(list(iter1))  # \u041f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0432 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044e iter2 = filter(lambda x: x > 5, range(10)) print(list(iter2))  # \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u043e \u0432\u0441\u0435\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u0432\u043e\u0434\u044f \u0438\u0445 \u043a \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e a = functools.reduce(lambda out, x: out + x, range(10)) print(a)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [6, 7, 8, 9] 45<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">import functools  def sum(a,b):     return a + b  add_const = functools.partial(sum, 10)  print(add_const(5))<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">15<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0435 \u0441\u0440\u0430\u0437\u0443 \u0441\u0442\u0430\u043d\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f partial (\u0438 \u0437\u0430\u0447\u0435\u043c \u043e\u043d\u0430 \u043d\u0443\u0436\u043d\u0430), \u043d\u0435 \u0440\u0430\u0441\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0439\u0442\u0435\u0441\u044c, \u0432\u044b \u043d\u0435 \u043e\u0434\u0438\u043d\u043e\u043a\u0438 :). \u0412\u043e\u0442, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u0442\u0435\u043c\u0430 \u043d\u0430 Stackoverflow: \u00ab<a href=\"https:\/\/stackoverflow.com\/questions\/15331726\/how-does-functools-partial-do-what-it-does\" rel=\"nofollow noopener noreferrer\">I am not able to get my head on how the partial works<\/a>\u00bb. \u0422\u0430\u043c, \u043a\u0441\u0442\u0430\u0442\u0438, \u0435\u0441\u0442\u044c \u0441\u043e\u0432\u0435\u0442, \u043a\u0430\u043a partial \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u043f\u0440\u0438 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 pipe \u0441 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0438\u043c\u0435\u044e\u0449\u0438\u0445 \u0440\u0430\u0437\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<h3 id=\"any-all\">Any, All<\/h3>\n<p>  <\/p>\n<p>any() \u0432\u0435\u0440\u043d\u0435\u0442 True, \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u0438\u043d \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0438\u0441\u0442\u0438\u043d\u0435\u043d, all() \u0432\u0435\u0440\u043d\u0435\u0442 True \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0441\u0442\u0438 \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">animals = [\"Squirrel\", \"Beaver\", \"Fox\"] sentence = \"Bison likes squirrels and beavers\"  any_animal: bool = any(animal.lower() in sentence.lower() for animal in animals) print(any_animal)  all_animal: bool = all(animal.lower() in sentence.lower() for animal in animals) print(all_animal)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">True False<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"fayly\">\u0424\u0430\u0439\u043b\u044b<\/h3>\n<p>  <\/p>\n<p>\u0424\u0430\u0439\u043b\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0442\u043e\u044f\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0441\u043e\u0431\u043d\u044f\u043a\u043e\u043c \u043e\u0442 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u0430\u043a \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u044e\u0449\u0438\u0435 \u043d\u0435 \u0441\u0438\u044e\u043c\u0438\u043d\u0443\u0442\u043d\u0443\u044e \u0442\u043e\u0440\u043e\u043f\u043b\u0438\u0432\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u043d\u0435\u043a\u0438\u043c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u043c \u044d\u043d\u0435\u0440\u0433\u043e\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0430\u043a \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 <em>\u043d\u0430 \u0437\u0430\u0432\u0442\u0440\u0430<\/em>, \u0438\u043b\u0438, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0430\u043c \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 <em>\u043d\u0435\u0434\u0435\u043b\u044e \u043d\u0430\u0437\u0430\u0434<\/em>, \u0442\u043e \u0432\u0430\u043c, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438. \u0412 \u0444\u0430\u0439\u043b\u0430\u0445 \u0436\u0435 \u043e\u0441\u044f\u0434\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0431\u0430\u0437\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438 \u043d\u0438\u0436\u0435.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">f = open(\"f.txt\", mode='r', encoding=\"utf-8\", newline=None)  print(f.read())<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Hello from file!<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u044b\u0442\u044b\u0432\u0430\u0435\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0441\u043a\u0438\u0439 \u0437\u0443\u0434 \u0434\u0430\u0436\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438, \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e \u2014 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0439\u0442\u0435 \u0432 IDE \u0432\u0441\u0435 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435 \u043a\u0443\u0441\u043a\u0438 \u043a\u043e\u0434\u0430, \u043d\u0435 \u043d\u0430\u0434\u043e \u043d\u0430 \u043d\u0438\u0445 <em>\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c<\/em>, \u0438\u0445 \u043d\u0430\u0434\u043e \u0432\u0438\u0434\u043e\u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c, \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0434\u043e\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c; \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043d\u0446\u044b \u0441\u0432\u044f\u0436\u0443\u0442\u0441\u044f, \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u043f\u043e\u0439\u043c\u0435\u0442\u0435, \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u0443\u0435\u0442 \u044d\u0442\u043e\u0442 \u043a\u0443\u0441\u043e\u0447\u0435\u043a \u043a\u043e\u0434\u0430, \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u043c\u0435\u043b\u044c\u043a\u043d\u0451\u0442 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0430\u044f \u0438\u0441\u043a\u043e\u0440\u043a\u0430 \u0438 \u0432\u0430\u0448\u0430 \u043a\u0432\u0430\u043b\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043a\u0430\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0440\u0430\u0441\u0442\u0451\u0442. <\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u0436\u0438\u043c\u044b (mode):<br \/>  &#171;r&#187; \u2014 \u0447\u0442\u0435\u043d\u0438\u0435 (\u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e)<br \/>  &#171;w&#187; \u2014 \u0437\u0430\u043f\u0438\u0441\u044c (\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0432 \u0444\u0430\u0439\u043b\u0435, \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0451\u0440\u0442\u0430)<br \/>  &#171;x&#187; \u2014 \u044d\u043a\u0441\u043a\u043b\u044e\u0437\u0438\u0432\u043d\u043e\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u0437\u0430\u043f\u0438\u0441\u044c; \u0435\u0441\u043b\u0438 \u0444\u0430\u0439\u043b \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 FileExistsError<br \/>  &#171;a&#187; \u2014 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0432 \u043a\u043e\u043d\u0435\u0446 \u0444\u0430\u0439\u043b\u0430<br \/>  &#171;w+&#187; \u2014 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u043f\u0438\u0441\u044c<br \/>  &#171;r+&#187; \u2014 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0441 \u043d\u0430\u0447\u0430\u043b\u0430 \u0444\u0430\u0439\u043b\u0430<br \/>  &#171;a+&#187; \u2014 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0441 \u043a\u043e\u043d\u0446\u0430 \u0444\u0430\u0439\u043b\u0430<br \/>  &#171;t&#187; \u2014 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0440\u0435\u0436\u0438\u043c (&#171;rt&#187;, &#171;wt&#187; \u0438 \u0442. \u0434.; \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e)<br \/>  &#171;b&#187; \u2014 \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c (&#171;rb&#187;, &#171;wb&#187;, &#171;xb&#187; \u0438 \u0442. \u0434.) <\/p>\n<p>  <\/p>\n<p>encoding=None \u2014 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0430 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e (\u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0441\u043c. getpreferredencoding()). \u0415\u0441\u043b\u0438 \u043d\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439, \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0432\u0435\u0437\u0434\u0435 encoding=&#187;utf-8&#8243;; \u0431\u0435\u0437 \u044d\u0442\u043e\u0433\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u0442\u0435\u043a\u0441\u0442 \u0437\u0430\u043f\u0438\u0448\u0435\u0442\u0441\u044f \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0432 \u0432\u0438\u0434\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u043d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  <\/p>\n<p>newline=None \u2014 \u043f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u043a\u043e\u043d\u0446\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0432 &#171;\\n&#187;; \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, &#171;\\n&#187; \u0431\u0443\u0434\u0443\u0442 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u043a\u043e\u043d\u0446\u0430 \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438:<br \/>  <em>FileNotFoundError<\/em> \u043f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 &#171;r&#187; \u0438\u043b\u0438 &#171;r+&#187;.<br \/>  <em>FileExistsError<\/em> \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 &#171;x&#187;.<br \/>  <em>IsADirectoryError<\/em>, <em>PermissionError<\/em> \u2014 \u0432 \u043b\u044e\u0431\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435. <\/p>\n<p>  <\/p>\n<h3 id=\"chtenie-iz-fayla\">\u0427\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430<\/h3>\n<p>  <\/p>\n<p>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0444\u0430\u0439\u043b \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442.<br \/>  \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u044b \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 (\u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u043d\u0438\u0436\u0435), \u0442. \u0435. \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0432\u0438\u0434\u0430 &#171;with open&#8230;&#187;. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0439\u0434\u0435\u0442 \u043d\u0435 \u0442\u0430\u043a, \u043a\u0430\u043a \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u043e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b \u043d\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u0430\u0439\u043b\u043e\u043c), \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u00ab\u0437\u0430\u0447\u0438\u0441\u0442\u0438\u0442 \u0445\u0432\u043e\u0441\u0442\u044b\u00bb, \u0438 \u0432\u0430\u0448\u0430 \u043e\u043f\u043b\u043e\u0448\u043d\u043e\u0441\u0442\u044c \u043d\u0435 \u043e\u0442\u0440\u0430\u0437\u0438\u0442\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">with open(\"f.txt\", encoding=\"utf-8\") as f:     chars = f.read(5)  # Reads chars\/bytes or until EOF     print(chars)      f.seek(0)  # Moves to the start of the file. Also seek(offset) and seek(\u00b1offset, anchor), where anchor is 0 for start, 1 for current position and 2 for end      lines: list[str] = f.readlines()  # Also readline()     print(lines)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Hello ['Hello from file!']<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"zapis-v-fayl\">\u0417\u0430\u043f\u0438\u0441\u044c \u0432 \u0444\u0430\u0439\u043b<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">with open(\"f.txt\", \"w\", encoding=\"utf-8\") as f:     f.write(\"Hello from file!\")  # \u0418\u043b\u0438 f.writelines(&lt;collection>)<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"json\">JSON<\/h3>\n<p>  <\/p>\n<p>\u0427\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import json  d: dict = {1: \"Lemon\", 2: \"Apple\", 3: \"Banana!\"}  object_as_string: str = json.dumps(d, indent=2) print(object_as_string)  restored_object = json.loads(object_as_string)  # Write object to JSON file with open(\"1.json\", 'w', encoding='utf-8') as file:     json.dump(d, file, indent=2)  # Read object from JSON file with open(\"1.json\", encoding='utf-8') as file:     restored_from_file = json.load(file)  print(restored_from_file) <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">{   \"1\": \"Lemon\",   \"2\": \"Apple\",   \"3\": \"Banana!\" } {'1': 'Lemon', '2': 'Apple', '3': 'Banana!'}<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"pickle\">Pickle<\/h3>\n<p>  <\/p>\n<p>\u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import pickle  d: dict = {1: \"Lemon\", 2: \"Apple\", 3: \"Banana!\"}  # \u0417\u0430\u043f\u0438\u0441\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u0444\u0430\u0439\u043b with open(\"1.bin\", \"wb\") as file:     pickle.dump(d, file)  # \u0427\u0442\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 with open(\"1.bin\", \"rb\") as file:     restored_from_file = pickle.load(file)  print(restored_from_file)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">{1: 'Lemon', 2: 'Apple', 3: 'Banana!'}<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"protocol-buffers\">Protocol Buffers<\/h3>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c\u0443\u044e \u0432\u0441\u0435\u043c\u0438 \u044f\u0437\u044b\u043a\u0430\u043c\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (\u043a\u0430\u043a JSON) \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0449\u0443\u044e \u043c\u0430\u043b\u043e \u043c\u0435\u0441\u0442\u0430 (\u043a\u0430\u043a Pickle), \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 Protocol Buffers (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Protocol_Buffers\" rel=\"nofollow noopener noreferrer\">Wikipedia<\/a>, <a href=\"https:\/\/developers.google.com\/protocol-buffers\/docs\/pythontutorial\" rel=\"nofollow noopener noreferrer\">\u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0434\u043b\u044f Python<\/a>). \u0415\u0441\u0442\u044c \u0435\u0449\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/google.github.io\/flatbuffers\/\" rel=\"nofollow noopener noreferrer\">FlatBuffers<\/a>, <a href=\"https:\/\/avro.apache.org\/\" rel=\"nofollow noopener noreferrer\">Apache Avro<\/a> \u0438\u043b\u0438 <a href=\"https:\/\/thrift.apache.org\/\" rel=\"nofollow noopener noreferrer\">Thrift<\/a>.<\/p>\n<p>  <\/p>\n<h3 id=\"puti-paths\">\u041f\u0443\u0442\u0438 (Paths)<\/h3>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u043d\u0435 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0431\u0435\u0437 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u043c\u0438 \u043f\u0443\u0442\u044f\u043c\u0438.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from os import getcwd, path, listdir from pathlib import Path  s1: str = getcwd()  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0440\u0430\u0431\u043e\u0447\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e print(s1)  s2: str = path.abspath(\"f.txt\")  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0443\u0442\u044c print(s2)  s3: str = path.basename(s2)  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 s4: str = path.dirname(s2)  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0443\u0442\u044c \u0431\u0435\u0437 \u0444\u0430\u0439\u043b\u0430 t1: tuple = path.splitext(s2)  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u0440\u0442\u0435\u0436 \u0438\u0437 \u043f\u0443\u0442\u0438 \u0438 \u0438\u043c\u0435\u043d\u0438 \u0444\u0430\u0439\u043b\u0430 print(s3, s4, t1)  p = Path(s2) st = p.stat() print(st)  b1: bool = p.exists() b2: bool = p.is_file() b3: bool = p.is_dir() print(b1, b2, b3)  c: list = listdir(path=s1)  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u043c\u0435\u043d \u0444\u0430\u0439\u043b\u043e\u0432, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0445\u0441\u044f \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 print(c)  s5: str = p.stem  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 \u0431\u0435\u0437 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f s6: str  = p.suffix  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 t2: tuple = p.parts  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043f\u0443\u0442\u0438 \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 print(s5, s6, t2)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">c:\\Works\\amaargiru\\pycore c:\\Works\\amaargiru\\pycore\\f.txt f.txt c:\\Works\\amaargiru\\pycore ('c:\\\\Works\\\\amaargiru\\\\pycore\\\\f', '.txt') os.stat_result(st_mode=33206, st_ino=2251799814917120, st_dev=3628794147, st_nlink=1, st_uid=0, st_gid=0, st_size=16, st_atime=1662468638, st_mtime=1662468638, st_ctime=1661089564) True True False ['.git', '.gitignore', '.pytest_cache', '01_python.ipynb', '01_python.md', '02_postgre.md', '03_architecture.md', '04_algorithms.ipynb', '04_algorithms.md', '05_admin_devops.md', '06_pytest_mock.ipynb', '06_pytest_mock.md', '07_fastapi.md', '08_flask.md', '1.bin', '1.json', 'compose_readme.bat', 'coupling_vs_cohesion.svg', 'f.txt', 'gitflow.svg', 'graph_for_dfs.jpg', 'pycallgraph3.png', 'readme.md'] f .txt ('c:\\\\', 'Works', 'amaargiru', 'pycore', 'f.txt')<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"prosteyshie-vychisleniya--sum-count-min-max\">\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u2014 Sum, Count, Min, Max<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">a: list[int] = [1, 2, 3, 4, 5, 2, 2]  s = sum(a) print(s)  c = a.count(2)  # \u0412\u0435\u0440\u043d\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0439 print(c)  mn = min(a) print(mn)  mx = max(a) print(mx)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">19 3 1 5<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435\u0441\u044c \u043a <a href=\"https:\/\/docs.python.org\/3\/library\/functions.html\" rel=\"nofollow noopener noreferrer\">\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c<\/a>, \u0442\u0430\u043c \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u043a\u043e\u0435-\u0447\u0442\u043e, \u043a\u0430\u0441\u0430\u044e\u0449\u0435\u0435\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u043d\u043e\u0439 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438.<\/p>\n<p>  <\/p>\n<h3 id=\"bazovaya-matematika\">\u0411\u0430\u0437\u043e\u0432\u0430\u044f \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">from math import pi  a: float = pi ** 2  # Or pow(pi, 2) print(f\"Power: {a}\")  b: float = round(pi, 2) print(f\"Round: {b}\")  c: int = round(256, -2) print(f\"Int round: {c}\")  d: float = abs(-pi) print(f\"Abs: {d}\")  e: float = abs(10+10j)  # Or e: float = abs(complex(real=10, imag=10)) print(f\"Complex abs: {e}\") <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Power: 9.869604401089358 Round: 3.14 Int round: 300 Abs: 3.141592653589793 Complex abs: 14.142135623730951<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"pobitovye-operacii\">\u041f\u043e\u0431\u0438\u0442\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">a: int = 0b01010101 b: int = 0b10101010  print(f\"And: 0b{a&amp;b:08b}\") print(f\"Or: 0b{a|b:08b}\") print(f\"Xor: 0b{a^b:08b}\") print(f\"Left shift: 0b{a &lt;&lt; 4:08b}\") print(f\"Right shift: 0b{b >> 4:08b}\") print(f\"Not: 0b{~a:08b}\")<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">And: 0b00000000 Or: 0b11111111 Xor: 0b11111111 Left shift: 0b10101010000 Right shift: 0b00001010 Not: 0b-1010110<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"podschet-bitov\">\u041f\u043e\u0434\u0441\u0447\u0435\u0442 \u0431\u0438\u0442\u043e\u0432<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">a: int = 4242 print(f\"{a} in binary format: 0b{a:b}\")  c = a.bit_count()  # Returns the number of ones in the binary representation of the absolute value of the integer print(f\"Bit count: {c}\")<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">4242 in binary format: 0b1000010010010 Bit count: 4<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"fractions\">Fractions<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">from fractions import Fraction  f = Fraction(\"0.2\").as_integer_ratio()  print(f)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">(1, 5)<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"evklidovo-rasstoyanie-mezhdu-dvumya-tochkami\">\u0415\u0432\u043a\u043b\u0438\u0434\u043e\u0432\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0442\u043e\u0447\u043a\u0430\u043c\u0438<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">import math  p1 = (0.22, 1, 12) p2 = (-0.12, 3, 7)  print(math.dist(p1, p2))<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">5.39588732276722<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"numpy\">NumPy<\/h3>\n<p>  <\/p>\n<p>\u041c\u0438\u043d\u0438-\u044f\u0437\u044b\u043a \u0434\u043b\u044f \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438. \u041d\u0430 \u0443\u0434\u0430\u0447\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u0445 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0441\u043e\u0442\u043d\u0438 \u0440\u0430\u0437 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u0415\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u0431\u044b\u0441\u0442\u0440\u0430\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 GPU, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/github.com\/cupy\/cupy\" rel=\"nofollow noopener noreferrer\">CuPy<\/a> \u0438 \u043e\u043f\u044f\u0442\u044c-\u0442\u0430\u043a\u0438 <a href=\"https:\/\/medium.com\/rapids-ai\/single-gpu-cupy-speedups-ea99cbbb0cbb\" rel=\"nofollow noopener noreferrer\">\u043e\u0431\u0435\u0449\u0430\u0435\u0442<\/a> \u0441\u0442\u043e\u043a\u0440\u0430\u0442\u043d\u044b\u0439 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0436\u0435 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 NumPy. \u0422\u0430\u043a \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Fast_Fourier_transform\" rel=\"nofollow noopener noreferrer\">FFT<\/a> \u0438\u043b\u0438 \u0435\u0449\u0435 \u043a\u0430\u043a\u043e\u0439 \u0447\u0438\u0441\u043b\u043e\u0433\u0440\u044b\u0437, \u0442\u043e \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c. \u0415\u0441\u043b\u0438 \u0432\u044b \u0434\u0440\u0443\u0436\u0438\u0442\u0435 \u0441 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u043c, \u0442\u043e \u0438\u0437\u0443\u0447\u0430\u0439\u0442\u0435 <a href=\"https:\/\/numpy.org\/doc\/stable\/\" rel=\"nofollow noopener noreferrer\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0430\u043d\u0443\u0430\u043b<\/a>, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u2014 \u043d\u0430 \u00ab\u0425\u0430\u0431\u0440\u0435\u00bb \u0435\u0441\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/post\/352678\/\">\u043f\u0435\u0440\u0435\u0432\u043e\u0434<\/a> (\u043a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430, \u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438, \u0442\u0430\u043c \u043d\u0435\u043c\u0430\u043b\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e).<\/p>\n<p>  <\/p>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0442\u0443\u0442 \u043c\u044b \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0433\u0440\u0430\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u044f\u0437\u044b\u043a\u0430 \u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438. \u041d\u0430\u0434\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u0443\u0441\u043f\u0435\u0445 Python \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u0431\u043e\u0433\u0430\u0442\u0441\u0442\u0432\u0435 \u0435\u0433\u043e \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b (\u0445\u043e\u0442\u044f, \u0432\u043f\u0440\u043e\u0447\u0435\u043c, \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0438 \u043f\u0440\u043e JavaScript, \u0438 \u043f\u0440\u043e C#); \u0441\u0430\u043c \u044f\u0437\u044b\u043a \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0431\u043e\u0433\u0430\u0442\u0443\u044e, \u043d\u043e \u0432\u0441\u0451 \u0436\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u0435\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d; \u044d\u0442\u043e \u043a\u0430\u043a \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0435 \u043a\u0443\u0431\u0438\u043a\u0438 \u041b\u0435\u0433\u043e. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441 \u043d\u0443\u043b\u044f \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c Python&#8217;\u0435, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a Python (\u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u043a\u043e\u043d\u043a\u0443\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0445) \u0441\u0438\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043d\u0438\u0442\u0441\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, NumPy \u2014 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043d\u043e \u0432 \u043c\u0438\u0440\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u044b Python-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 <em>\u043d\u0438\u043a\u043e\u0433\u0434\u0430<\/em> \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0441 NumPy, \u043f\u0440\u043e\u0441\u0442\u043e \u0432 \u0441\u0438\u043b\u0443 \u0441\u0432\u043e\u0435\u0433\u043e \u043a\u0440\u0443\u0433\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u044f\u0437\u0430\u043d\u043d\u043e\u0441\u0442\u0435\u0439.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0435\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u044d\u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u0448\u0443\u0442\u043e\u0447\u043d\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u2014 \u043a\u0430\u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0432\u043f\u0435\u0440\u0435\u0434, \u043a\u0430\u043a\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438\u0437\u0443\u0447\u0430\u0442\u044c, \u0432\u0435\u0434\u044c \u0437\u043d\u0430\u043d\u0438\u044f \u0447\u0438\u0441\u0442\u043e\u0433\u043e Python, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0437\u044e\u043c\u0435.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u043c \u0432\u0430\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u043e\u0432\u0435\u0442. \u0415\u0436\u0435\u0433\u043e\u0434\u043d\u043e \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f JetBrains (\u0434\u0435\u043b\u0430\u044e\u0449\u0430\u044f \u0441\u0440\u0435\u0434\u0438 \u043f\u0440\u043e\u0447\u0435\u0433\u043e \u043e\u0447\u0435\u043d\u044c \u043a\u043b\u0430\u0441\u0441\u043d\u0443\u044e IDE PyCharm) \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442 \u0432\u0441\u0435\u043c\u0438\u0440\u043d\u044b\u0439 \u043e\u043f\u0440\u043e\u0441 Python-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u0430 \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432 \u0432\u0438\u0434\u0435 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e <a href=\"https:\/\/lp.jetbrains.com\/python-developers-survey-2021\/\" rel=\"nofollow noopener noreferrer\">Python Developers Survey Results<\/a>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u0447\u0438\u0442\u0430\u0435\u0442\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f, \u0442\u043e \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u0442\u0430\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0447\u0451\u0442\u043a\u0438\u0435 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u044b: \u0441\u043a\u0430\u0436\u0435\u043c, \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u00abData science frameworks and libraries\u00bb \u0432 \u0442\u043e\u043f\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f NumPy, Pandas (\u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d \u043d\u0438\u0436\u0435) \u0438 Matplotlib; \u0432 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043e\u0442\u0440\u044b\u0432\u043e\u043c \u043b\u0438\u0434\u0438\u0440\u0443\u0435\u0442 pytest (\u0441\u043c\u043e\u0442\u0440\u0438 \u043d\u0438\u0436\u0435), \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043e\u0431\u043b\u0430\u0441\u0442\u044f\u0445 \u0432\u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0440\u044b\u0432\u0430\u044e\u0442\u0441\u044f Flask (Django \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0441 \u043a\u0440\u043e\u0448\u0435\u0447\u043d\u044b\u043c \u043e\u0442\u0440\u044b\u0432\u043e\u043c), SQLAlchemy (vs Django ORM) \u0438 PostgreSQL (vs SQLite), \u043f\u0440\u043e \u043d\u0438\u0445 \u043c\u044b \u0442\u043e\u0436\u0435 \u0435\u0449\u0435 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c. \u0422\u0430\u043a \u0447\u0442\u043e \u0432 \u0446\u0435\u043b\u043e\u043c, \u043e\u0431\u0449\u0435\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043c\u043e\u0436\u043d\u043e.<\/p>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a NumPy. \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 NumPy \u043b\u0435\u0436\u0430\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u044b, \u0430 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430 (\u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0432\u044b \u0443\u0436\u0435 \u043f\u043e\u0437\u043d\u0430\u043b\u0438 \u043f\u0440-\u0440-\u0440\u0435\u043b-\u043b-\u043b\u0435\u0441\u0442\u044c \u0441\u043f\u0438\u0441\u043a\u043e\u0432 Python). \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import numpy as np  a1 = np.array([1, 2, 3, 4, 5], float)  # \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 print(a1[0:2])  a2 = np.zeros(5)  # \u041c\u0430\u0441\u0441\u0438\u0432, \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0439 \u043d\u0443\u043b\u044f\u043c\u0438 print(a2)  a3 = np.arange(0, 6, 1)  # \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430, np.arange(from_inclusive, to_exclusive, step_size) print(a3)  a4 = np.random.randint(6, size=10)  # \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, np.random.randint(low_inclusive, high_exclusive=None, size=None, dtype=int) print(a4)  a5 = np.random.randint(6, size=(2, 5))  # \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u043d\u043e\u0433\u043e\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f print(a5)  print(a5.shape)  # \u0427\u0438\u0441\u043b\u043e \u0441\u0442\u0440\u043e\u043a \u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435  print(a5.dtype)  # \u0422\u0438\u043f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445  print(1 in a5)  # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">[1. 2.] [0. 0. 0. 0. 0.] [0 1 2 3 4 5] [2 2 4 0 0 0 0 4 0 5] [[1 0 3 5 0]  [3 1 4 2 2]] (2, 5) int32 True<\/code><\/pre>\n<p>  <\/p>\n<p>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 (<a href=\"https:\/\/numpy.org\/doc\/stable\/reference\/routines.math.html\" rel=\"nofollow noopener noreferrer\">\u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a<\/a>):<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import numpy as np  a1 = np.array([1, 2, 3, 4, 5]) a2 = np.array([6, 7, 8, 9, 10])  a3 = a1 + 1 print(a3)  a4 = a1 + a2 print(a4)  a5 = a1 ** 3 print(a5)  a6 = a1 ** a2 print(a6)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">[2 3 4 5 6] [ 7  9 11 13 15] [  1   8  27  64 125] [      1     128    6561  262144 9765625]<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u043e\u043e\u0431\u0449\u0435, \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u044b\u0435 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u043c\u043d\u043e\u0433\u043e\u043c\u0435\u0440\u043d\u044b\u043c\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438 \u2014 \u044d\u0442\u043e \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u00ab\u0444\u0438\u0448\u043a\u0430\u00bb NumPy. \u0412\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0435: \u0432\u043e\u0437\u044c\u043c\u0438 \u0442\u0430\u043a\u0438\u0435-\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0438 \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0439 \u043d\u0430\u0434 \u043d\u0438\u043c\u0438 \u0442\u0430\u043a\u0443\u044e-\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e. \u0414\u0430\u043b\u0435\u0435 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u00ab\u043f\u0440\u043e\u0432\u0430\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f\u00bb \u0432 \u0432\u044b\u0441\u043e\u043a\u043e\u0441\u043a\u043e\u0440\u043e\u0441\u0442\u043d\u043e\u0435 \u044f\u0434\u0440\u043e NumPy, \u0433\u0434\u0435 \u043a \u043d\u0438\u043c \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u0441\u044e \u043c\u043e\u0449\u044c \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u043d\u044c\u0448\u0435 \u0431\u044b\u043b\u0430 \u0432\u0430\u043c \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 (\u043d\u0443, \u0438\u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u043d\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e) \u0438\u0437-\u0437\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 Python-\u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430. \u0422\u0430\u043a \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u044b\u0442\u0430\u0435\u0442\u0435\u0441\u044c \u0432 \u0446\u0438\u043a\u043b\u0435 \u0438\u0442\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 NumPy, \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u043d\u0438\u0436\u043d\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u043f\u043e\u0440\u0446\u0438\u044f\u043c\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 row), \u0442\u043e \u0438\u043c\u0435\u0439\u0442\u0435 \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 NumPy \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e; \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0440\u0435\u0448\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u0431\u0435\u0437 \u0438\u0442\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. <\/p>\n<p>  <\/p>\n<h3 id=\"sum-min-max\">Sum, Min, Max<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">import numpy as np  a1 = np.random.randint(6, size=(2, 10))  # NumPy \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u0432 \u0432\u0438\u0434\u043e\u0432 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u041f\u0443\u0430\u0441\u0441\u043e\u043d\u0430 \u0438 \u0421\u0442\u044c\u044e\u0434\u0435\u043d\u0442\u0430 print(a1)  s = np.sum(a1)  # \u0421\u0443\u043c\u043c\u0430 \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 print(s)  mn = a1.min(axis=0)  # \u041d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435 print(mn)  mx = a1.max(axis=1)  # \u041d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 print(mx)  amin = a1.argmin(axis=0)  # \u0418\u043d\u0434\u0435\u043a\u0441\u044b \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435 print(amin)  amax = a1.argmax(axis=1)  # \u0418\u043d\u0434\u0435\u043a\u0441\u044b \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 print(amax)  uniq = np.unique(a1)  # \u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 print(uniq)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">[[3 0 4 1 0 5 4 0 1 3]  [0 3 4 0 0 1 4 0 5 4]] 42 [0 0 4 0 0 1 4 0 1 3] [5 5] [1 0 0 1 0 1 0 0 0 0] [5 8] [0 1 3 4 5]<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u043e\u043c\u0430\u0448\u043d\u0435\u0433\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c prod(), mean(), var(), std(), median(), cov() \u0438 corrcoef().<\/p>\n<p>  <\/p>\n<p>\u0424\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import numpy as np  a = np.random.randint(6, size=(3, 5)) print(a)  a1 = a.reshape((5, 3))  # \u0424\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c, \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 view \u043d\u0430 \u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 print(a1)  a.shape = (5, 3)  # \u0424\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 in-place print(a)  print(a.shape) a = a[:, :, np.newaxis]  # \u0423\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441 2 \u0434\u043e 3 print(a) print(a.shape)  a = a.flatten()  # \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f \u0432 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 print(a) print(a.shape)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">[[5 5 5 1 1]  [0 2 0 5 5]  [0 2 5 4 5]] [[5 5 5]  [1 1 0]  [2 0 5]  [5 0 2]  [5 4 5]] [[5 5 5]  [1 1 0]  [2 0 5]  [5 0 2]  [5 4 5]] (5, 3) [[[5]   [5]   [5]]   [[1]   [1]   [0]]   [[2]   [0]   [5]]   [[5]   [0]   [2]]   [[5]   [4]   [5]]] (5, 3, 1) [5 5 5 1 1 0 2 0 5 5 0 2 5 4 5] (15,)<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import numpy as np import copy  a = np.random.randint(10, size=(4, 4)) print(a)  # \u041d\u0435\u0433\u043b\u0443\u0431\u043e\u043a\u0430\u044f (shallow) \u043a\u043e\u043f\u0438\u044f a1 = np.copy(a)  # \u0413\u043b\u0443\u0431\u043e\u043a\u0430\u044f (deep) \u043a\u043e\u043f\u0438\u044f a2 = copy.deepcopy(a)  # \u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 a3 = a  a[0, 0] = 10 print(a[0, 0] == a1[0, 0]) print(a[0, 0] == a2[0, 0]) print(a[0, 0] == a3[0, 0])<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">[[5 3 1 4]  [0 8 7 0]  [1 7 4 7]  [5 3 5 2]] False False True<\/code><\/pre>\n<p>  <\/p>\n<p>NumPy \u043e\u0447\u0435\u043d\u044c \u043c\u043e\u0449\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043d\u0435 \u0437\u0440\u044f \u0436\u0435 \u043e\u043d \u0441\u0442\u043e\u0438\u0442 \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u00abData science frameworks and libraries\u00bb \u043e\u0431\u0437\u043e\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u0438 \u0447\u0443\u0442\u044c \u0432\u044b\u0448\u0435. \u041d\u043e \u0443\u0433\u043b\u0443\u0431\u043b\u044f\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u043e\u0447\u0435\u043d\u044c \u0443\u0436 \u0433\u043b\u0443\u0431\u043e\u043a\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043d\u0430\u0448\u0435\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u043e\u0433\u043e \u043e\u0447\u0435\u0440\u043a\u0430, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u043d\u0435 \u0441\u0442\u043e\u0438\u0442; \u0432\u0440\u044f\u0434 \u043b\u0438 \u043f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u0432\u0430\u043c \u043a\u0440\u043e\u0432\u044c \u0438\u0437 \u043d\u043e\u0441\u0443 \u043d\u0443\u0436\u043d\u043e \u043e\u0441\u0432\u043e\u0438\u0442\u044c \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435, \u0442\u0435\u043d\u0437\u043e\u0440\u043d\u043e\u0435 \u0438 \u0432\u043d\u0435\u0448\u043d\u0435\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446 \u0438\u043b\u0438 \u043f\u043e\u0437\u043d\u0430\u0442\u044c (\u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c?) \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0443 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0430\u043b\u0433\u0435\u0431\u0440\u044b. \u0414\u0443\u043c\u0430\u044e, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043c\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0430\u0447\u043d\u0435\u043c \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u043b\u0438 \u0432\u044b\u0431\u043e\u0440 \u043e\u0441\u0438, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0430 \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432, \u0442\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u0431\u0443\u0434\u0435\u0442, \u0447\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u00ab\u043d\u0435 \u0432 \u043a\u043e\u043d\u044f \u043a\u043e\u0440\u043c\u00bb.<br \/>  \u041a \u0442\u043e\u043c\u0443 \u0436\u0435, \u0438\u0437\u0443\u0447\u0430\u044f \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u0438 \u0443\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044f NumPy, \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441\u043e\u0431\u043b\u0430\u0437\u043d \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f SciPy, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u0448\u0438\u0440\u043e\u043a\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u0430 \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e &#171;import scipy&#187; \u0443 \u043d\u0430\u0441 \u043d\u0430\u0447\u043d\u0451\u0442\u0441\u044f \u0443\u0436\u0435 \u043f\u043e\u043b\u043d\u043e\u0435 \u043d\u0435\u043f\u043e\u0442\u0440\u0435\u0431\u0441\u0442\u0432\u043e. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043a\u0430 \u043f\u0440\u043e\u0439\u0434\u0435\u043c \u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0439 \u043a\u0440\u043e\u043b\u0438\u0447\u044c\u0435\u0439 \u043d\u043e\u0440\u044b, \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0430 \u043e\u043d\u0430 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0433\u043b\u0443\u0431\u043e\u043a\u0430.<\/p>\n<p>  <\/p>\n<p>\u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0447\u0442\u043e \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0432\u043e\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0446\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u0443\u0440\u0441\u0430 NumPy \u2014 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u043c\u0438\u0440\u043e\u043c. \u0418\u0437\u0443\u0447\u0438\u0442\u0435 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 load\/save\/savez (\u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0438) \u0438 loadtxt\/savetxt (\u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442).<\/p>\n<p>  <\/p>\n<h3 id=\"pandas\">Pandas<\/h3>\n<p>  <\/p>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043f\u043e\u0432\u0435\u0440\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 NumPy.<br \/>  \u0412 \u043f\u0435\u0440\u0432\u043e\u043c, \u0433\u0440\u0443\u0431\u043e\u043c \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u0438 pandas \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043a\u0430\u043a \u0441\u0432\u044f\u0437\u043a\u0443 \u00abExcel + VisualBasic-\u0441\u043a\u0440\u0438\u043f\u0442\u044b\u00bb, \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0443\u044e \u0438 \u0443\u0434\u043e\u0431\u043d\u0443\u044e. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0441\u0432\u043e\u0435\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0439 \u043c\u043e\u0441\u0442\u0438\u043a \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f\u043c\u0438 Python-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430, \u0434\u0430\u0442\u0430-\u0441\u0430\u0439\u0435\u043d\u0442\u0438\u0441\u0442\u0430 \u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u0442\u044c\u0441\u044f \u0432 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u043e\u0447\u0438\u0441\u0442\u043a\u0435 \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0442\u0447\u0435\u0442\u043e\u0432, \u0430 \u043d\u0435 \u043d\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438. Pandas \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0448\u0438\u0440\u043e\u043a\u0438\u0439 \u0441\u043f\u0435\u043a\u0442\u0440 \u00ab\u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0441\u0442\u0435\u0439\u00bb \u043f\u0440\u0438 \u0432\u044b\u0432\u043e\u0434\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u0443\u044e \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0443 (heatmap) \u0438\u043b\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435 \u043e\u0442 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e (bar chart).<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u00ab\u0440\u0430\u0441\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c\u00bb pandas, \u043f\u043e-\u0445\u043e\u0440\u043e\u0448\u0435\u043c\u0443 \u043d\u0430\u0434\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0440\u0430\u0437\u0432\u0435\u0441\u0438\u0441\u0442\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u043c\u044b, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0433\u0440\u0443\u0436\u0430\u0442\u044c\u0441\u044f \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u044b \u0433\u043b\u0443\u0431\u0438\u043d, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0438\u0433\u0440\u0430\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0441\u0430\u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u043c.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import pandas as pd  s = pd.Series([0, 1, 4, 7, 8, 10, 12]) print(s) print(s[2])<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">0     0 1     1 2     4 3     7 4     8 5    10 6    12 dtype: int64 4<\/code><\/pre>\n<p>  <\/p>\n<p>Series \u2014 \u0431\u0430\u0437\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 pandas. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0435\u0451 \u043a\u0430\u043a \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0438\u043b\u0438 \u043a\u0430\u043a \u0441\u0442\u0440\u043e\u043a\u0443 Excel, \u0441\u043c\u043e\u0442\u0440\u044f \u043f\u043e \u0442\u043e\u043c\u0443, \u043a\u0430\u043a\u0430\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u044f \u0432\u0430\u043c \u0431\u043b\u0438\u0436\u0435.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import pandas as pd  s = pd.Series([0, 1, 4, 7, 8, 10, 12], index=[\"a\", \"b\", \"c\", \"d\", \"x\", \"y\", \"z\"])  # \u0418\u043d\u0434\u0435\u043a\u0441\u044b Series \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e  print(s) print(s[\"x\"]) print(s[[\"x\", \"y\", \"z\"]])  # \u0412\u044b\u0431\u043e\u0440\u043a\u0430 print(s[s > 5])  # \u0424\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f  print(s.max())  # \u041c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043a\u0430\u043a \u0432 NumPy print(s.sum())<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">a     0 b     1 c     4 d     7 x     8 y    10 z    12 dtype: int64 8 x     8 y    10 z    12 dtype: int64 d     7 x     8 y    10 z    12 dtype: int64 12 42<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 Series \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f DataFrame, \u0432\u0442\u043e\u0440\u0430\u044f \u0431\u0430\u0437\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 pandas, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u043b\u0438\u0441\u0442 Excel.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import pandas as pd from pandas import DataFrame  s1 = pd.Series([0, 1, 4, 7, 8, 10, 12]) s2 = pd.Series([0, 100, 200, 300, 600, 900, 1200])  df = pd.DataFrame([s1, s2]) print(df) print(df[1]) print(df[2][0]) print(df.iloc[0][2:4])<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">   0    1    2    3    4    5     6 0  0    1    4    7    8   10    12 1  0  100  200  300  600  900  1200 0      1 1    100 Name: 1, dtype: int64 4 2    4 3    7 Name: 0, dtype: int64<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0447\u0442\u043e-\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0444\u043e\u0440\u043c\u0443\u043b\u044b <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%98%D0%BD%D0%B4%D0%B5%D0%BA%D1%81_%D0%BC%D0%B0%D1%81%D1%81%D1%8B_%D1%82%D0%B5%D0%BB%D0%B0\" rel=\"nofollow noopener noreferrer\">\u0418\u041c\u0422<\/a> \u0432\u044b\u044f\u0441\u043d\u0438\u043c, \u043a\u0442\u043e \u0438\u0437 \u0437\u043d\u0430\u043c\u0435\u043d\u0438\u0442\u043e\u0441\u0442\u0435\u0439 \u043d\u0435 \u0441\u043b\u0435\u0434\u0438\u0442 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u0438 \u043e\u0431\u0437\u0430\u0432\u0435\u043b\u0441\u044f \u043b\u0438\u0448\u043d\u0438\u043c \u0432\u0435\u0441\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from pandas import DataFrame import matplotlib.pyplot as plt  def bmi(row):     return row[\"weight\"] \/ row[\"height\"] ** 2  if __name__ == '__main__':     celebs: dict = {\"Britney Spears\": {\"height\": 1.63, \"weight\": 57},                     \"Melanie Griffith\": {\"height\": 1.73, \"weight\": 63},                     \"Kylie Minogue\": {\"height\": 1.52, \"weight\": 46},                     \"Hulk Hogan\": {\"height\": 1.98, \"weight\": 137}}      df = DataFrame(celebs)  # \u0421\u043e\u0437\u0434\u0430\u0435\u043c DataFrame     df.loc[\"bmi\"] = df.apply(lambda row: bmi(row), axis=0)  # \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043c \u043d\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u0418\u041c\u0422     df = df.sort_values(by=\"bmi\", ascending=True, axis=1)  # \u0421\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c      print(df)      df.loc[\"bmi\"].plot.bar()  # \u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f     plt.show()<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">        Kylie Minogue  Melanie Griffith  Britney Spears  Hulk Hogan height       1.520000          1.730000        1.630000    1.980000 weight      46.000000         63.000000       57.000000  137.000000 bmi         19.909972         21.049818       21.453574   34.945414<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/post_images\/501\/fe2\/953\/501fe29532c00ff9b3e59fd7754455e7.png\" alt=\"png\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/501\/fe2\/953\/501fe29532c00ff9b3e59fd7754455e7.png\"\/><\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0425\u0430\u043b\u043a, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0435 \u0442\u043e\u043b\u0441\u0442\u044f\u043a, \u0430 \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u043e\u0440\u0442\u0441\u043c\u0435\u043d, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0444\u043e\u0440\u043c\u0443\u043b\u0430 \u0418\u041c\u0422 \u043c\u0430\u043b\u043e\u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u0430, \u043d\u043e \u043a\u0440\u043e\u0448\u043a\u0430 \u041a\u0430\u0439\u043b\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043f\u0435\u0440\u0435\u0434, \u0434\u0430\u0436\u0435 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0441\u0432\u043e\u0435\u0433\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0440\u043e\u0441\u0442\u0430.<\/p>\n<p>  <\/p>\n<h3 id=\"matplotlibseaborn\">Matplotlib\/Seaborn<\/h3>\n<p>  <\/p>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 matplotlib \u043c\u044b \u0443\u0436\u0435 \u0441\u043b\u0435\u0433\u043a\u0430 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0438 \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435. \u041f\u0440\u044f\u043c\u043e \u0437\u0434\u0435\u0441\u044c \u0438 \u043f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u0433\u043b\u0443\u0431\u043e\u043a\u043e \u043f\u043e\u0433\u0440\u0443\u0436\u0430\u0442\u044c\u0441\u044f \u0432 \u0440\u0430\u0437\u0431\u043e\u0440 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 matplotlib\/seaborn, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u043e\u0441\u043e\u0431\u043e\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0430 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442; \u0432\u0441\u0435 \u0432\u044b \u0432\u0438\u0434\u0435\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u0439 \u0432 \u043d\u0430\u0443\u0447\u043d\u043e\u0439 \u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0435 \u0438, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0432\u0441\u0435 \u044d\u0442\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u0438 \u0438 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043b\u044f \u0437\u0430\u0442\u0440\u0430\u0432\u043a\u0438 \u043d\u0430\u0440\u0438\u0441\u0443\u0435\u043c \u043f\u0430\u0440\u0443 \u0441\u0438\u043c\u043f\u0430\u0442\u0438\u0447\u043d\u044b\u0445 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0441\u0442\u044c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u043d\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b. <\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u043b\u043e\u0432\u0430\u044f \u043a\u0430\u0440\u0442\u0430 (heatmap), \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0447\u043b\u0435\u043d\u043e\u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from random import randrange  import numpy as np import matplotlib.pyplot as plt import uuid  targets = [\"authorities\", \"humans\", \"parrots\", \"cars\", \"motorcycles\", \"buildings\", \"warehouses\"] robots = [\"Terminator #\" + str(uuid.uuid4())[:5] for _ in range(7)] harvest = np.array([[randrange(i * j) for i in range(10, 80, 10)] for j in range(1, 8)])  fig, ax = plt.subplots() im = ax.imshow(harvest)  ax.set_xticks(np.arange(len(robots)), labels=robots) ax.set_yticks(np.arange(len(targets)), labels=targets) plt.setp(ax.get_xticklabels(), rotation=60, ha=\"right\", rotation_mode=\"anchor\")  for i in range(len(targets)):     for j in range(len(robots)):         text = ax.text(j, i, harvest[i, j], ha=\"center\", va=\"center\", color=\"w\")  ax.set_title(\"Targets destroyed\") fig.tight_layout()  plt.rcParams['figure.figsize'] = [4, 4] plt.rcParams['figure.dpi'] = 200 plt.show()<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/post_images\/eba\/76c\/412\/eba76c412c65b8139db64f7a7aebfc19.png\" alt=\"png\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/eba\/76c\/412\/eba76c412c65b8139db64f7a7aebfc19.png\"\/><\/p>\n<p>  <\/p>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f \u0442\u0435\u043f\u043b\u043e\u0432\u0430\u044f \u043a\u0430\u0440\u0442\u0430, \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 seaborn:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from random import randrange  import numpy as np import matplotlib.pyplot as plt import uuid  import seaborn as sns  sns.set_theme()  targets = [\"authorities\", \"humans\", \"parrots\", \"cars\", \"motorcycles\", \"buildings\", \"warehouses\"] robots = [\"Terminator #\" + str(uuid.uuid4())[:5] for _ in range(7)] harvest = np.array([[randrange(i * j) for i in range(10, 80, 10)] for j in range(1, 8)])  fig, ax = plt.subplots() im = ax.imshow(harvest)  ax.set_title(\"Targets destroyed\") plt.rcParams['figure.figsize'] = [4, 4] sns.heatmap(harvest, annot=True, fmt=\"d\", linewidths=.5, ax=ax, xticklabels=robots, yticklabels=targets) plt.setp(ax.get_xticklabels(), rotation=60, ha=\"right\", rotation_mode=\"anchor\") plt.xticks(rotation=60) plt.show()<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/post_images\/fce\/04a\/0d5\/fce04a0d5530e395ba123a3d045d9f2a.png\" alt=\"png\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/fce\/04a\/0d5\/fce04a0d5530e395ba123a3d045d9f2a.png\"\/><\/p>\n<p>  <\/p>\n<p>\u0410 \u0432\u043e\u0442 \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u00ab\u0414\u043e\u0441\u043a\u0430 \u043f\u043e\u0447\u0451\u0442\u0430\u00bb \u043f\u0440\u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0435 \u0432 3D:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import uuid from random import randrange  import matplotlib.cm as cm import matplotlib.colors as colors import matplotlib.pyplot as plt import numpy as np  targets = [\"authorities\", \"humans\", \"parrots\", \"cars\", \"motorcycles\", \"buildings\", \"warehouses\"] robots = [\"Terminator #\" + str(uuid.uuid4())[:5] for _ in range(7)] harvest = np.array([[randrange(i * j) for i in range(10, 80, 10)] for j in range(1, 8)])  fig = plt.figure(figsize=(5, 5)) ax = fig.add_subplot(projection='3d') ax.set_xticks(np.arange(len(robots)), labels=robots) ax.set_yticks(np.arange(len(targets)), labels=targets) plt.setp(ax.get_xticklabels(), rotation=45, ha=\"right\", rotation_mode=\"anchor\") plt.setp(ax.get_yticklabels(), ha=\"left\", rotation_mode=\"anchor\") ax.set_title(\"Our team\")  xx, yy = np.meshgrid(range(len(targets)), range(len(robots))) x1d, y1d = xx.ravel(), yy.ravel() harvest1d = harvest.ravel()  # Setup color scheme offset = harvest1d + np.abs(harvest1d.min()) fracs = offset.astype(float) \/ offset.max() norm = colors.Normalize(fracs.min(), fracs.max()) colors = cm.jet(norm(fracs))  ax.bar3d(x1d, y1d, np.zeros_like(x1d + y1d), 0.7, 0.7, harvest1d, color=colors)  plt.show() <\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/post_images\/a70\/52e\/4eb\/a7052e4eb1eba178f4ef91a78351ff7e.png\" alt=\"png\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a70\/52e\/4eb\/a7052e4eb1eba178f4ef91a78351ff7e.png\"\/><\/p>\n<p>  <\/p>\n<h3 id=\"neyronnye-seti\">\u041d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0435 \u0441\u0435\u0442\u0438<\/h3>\n<p>  <\/p>\n<p>\u0423\u0433\u043b\u0443\u0431\u0438\u0442\u044c\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0433\u043b\u0443\u0431\u043e\u043a\u043e \u0432 \u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0443 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043d\u0430\u0448\u0435\u0433\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f (\u043a\u0430\u043a\u0438\u043c-\u043d\u0438\u0431\u0443\u0434\u044c \u0442\u043e\u043c\u043e\u043c \u00ab\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 Deep Learning\u00bb \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043d\u0435\u0441\u0442\u0438 \u0441\u0435\u0431\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0442\u0440\u0430\u0432\u043c\u044b, \u0435\u0441\u043b\u0438 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e \u0443\u0440\u043e\u043d\u0438\u0442\u044c \u0441\u043e \u0441\u0442\u043e\u043b\u0430), \u0442\u0430\u043a \u0447\u0442\u043e \u0441\u043a\u043e\u043b\u044c\u0437\u043d\u0451\u043c \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u043f\u043e \u0432\u0435\u0440\u0445\u0443\u0448\u043a\u0430\u043c, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0413\u043b\u0443\u0431\u0438\u043d\u043d\u0430\u044f \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u0430\u044f \u0441\u0435\u0442\u044c (deep neural network) \u2014 \u044d\u0442\u043e, \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u044b\u0440\u0430\u0436\u0430\u044f\u0441\u044c, <em>\u043c\u043d\u043e\u0433\u043e\u0441\u043b\u043e\u0439\u043d\u0430\u044f<\/em> \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u0430\u044f \u0441\u0435\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0430\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0445 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439 \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439. \u0412 \u0445\u043e\u0434\u0443 \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u0442\u0430\u043a\u0438\u0435 \u0442\u0435\u0440\u043c\u0438\u043d\u044b, \u043a\u0430\u043a \u00ab\u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u043e\u0435 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u00bb, \u00ab\u0441\u043b\u0430\u0431\u044b\u0439 \u0418\u0418\u00bb, \u00ab\u0441\u0438\u043b\u044c\u043d\u044b\u0439 \u0418\u0418\u00bb; \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u043e\u043d\u044f\u0442\u0438\u0439 \u00ab\u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u00bb, \u00ab\u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u00bb \u0438 \u00ab\u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u00bb (\u0432\u043e\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/machine-learning\/concept-deep-learning-vs-machine-learning\" rel=\"nofollow noopener noreferrer\">\u0432\u0430\u0440\u0438\u0430\u043d\u0442<\/a> \u043e\u0442 Microsoft, \u0442\u0430\u043a\u0443\u044e \u0436\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443-\u043c\u0430\u0442\u0440\u0451\u0448\u043a\u0443 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0424\u0440\u0430\u043d\u0441\u0443\u0430 \u0428\u043e\u043b\u043b\u0435 \u0432 \u0441\u0432\u043e\u0435\u0439 \u043a\u043d\u0438\u0433\u0435 \u00ab\u0413\u043b\u0443\u0431\u043e\u043a\u043e\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 Python\u00bb), \u043d\u043e \u0441\u0435\u0439\u0447\u0430\u0441, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u043f\u0440\u0438 \u043d\u0435\u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u043e\u0431\u0449\u0435\u043d\u0438\u0438, \u0432\u0441\u0451 \u0447\u0430\u0449\u0435 \u0441\u0442\u0430\u0432\u0438\u0442\u0441\u044f \u0437\u043d\u0430\u043a \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0430 \u043c\u0435\u0436\u0434\u0443 \u00ab\u043c\u0430\u0448\u0438\u043d\u043d\u044b\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u043c\u00bb \u0438 \u00ab\u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u043e\u043c\u00bb; \u043f\u0440\u0438\u0447\u0451\u043c \u0432 \u0440\u0430\u0431\u043e\u0442\u0435, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u00ab\u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u00bb, \u0430 \u043f\u0440\u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0435 \u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u0439 \u2014 \u00ab\u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u00bb \ud83d\ude42 \u0414\u0435\u043b\u043e, \u043f\u043e \u0432\u0441\u0435\u0439 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u043b\u043e \u0441\u0430\u043c\u043e\u0439 \u043c\u043d\u043e\u0433\u043e\u043e\u0431\u0435\u0449\u0430\u044e\u0449\u0435\u0439 \u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u044e\u0449\u0435\u0439\u0441\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c\u044e \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f, \u0430 \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u043e\u043c \u0443\u0436\u0435 \u0434\u0430\u0432\u043d\u043e \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043b\u0438 \u0432\u0441\u044e \u044d\u0442\u0443 \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0437\u043d\u0430\u043d\u0438\u0439 \u043a\u0430\u043a \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0442\u043e\u0440\u044b \u043d\u0430\u0443\u043a\u0438, \u0442\u0430\u043a \u0438 \u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0441\u0442\u044b. <\/p>\n<p>  <\/p>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c, \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u043c \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0435 \u0441 TensorFlow \u0438\u043b\u0438 PyTorch \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043c\u0435\u043b\u043e \u0432\u0441\u0435\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0435\u0441\u044c AI, \u0430 \u0435\u0441\u043b\u0438 \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0433\u043b\u0443\u0431\u0438\u0442\u044c\u0441\u044f \u2014 \u0443\u0436 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u0435\u0439-\u0442\u043e \u043e\u0432\u043b\u0430\u0434\u0435\u0435\u0442\u0435.<br \/>  \u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0441\u0443\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u0435\u0439, \u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u044f:<\/p>\n<p>  <\/p>\n<p><strong>\u0414\u0430\u0442\u0430\u0441\u0435\u0442<\/strong> \u2014 \u043c\u0430\u0440\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0435\u0442\u0438 \u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. \u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u2014 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0441 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u044b\u043c\u0438 \u0446\u0438\u0444\u0440\u0430\u043c\u0438 \u0438 \u0431\u0443\u043a\u0432\u0430\u043c\u0438, \u0433\u0434\u0435 \u043f\u0440\u043e \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0442\u043e\u0447\u043d\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043a\u0430\u043a\u0430\u0439 \u0438\u043c\u0435\u043d\u043d\u043e \u0441\u0438\u043c\u0432\u043e\u043b \u0432 \u043d\u0451\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f; \u0442\u0430\u043a\u043e\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0438\u0441\u0442\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 (handwritten text recognition, HTR). \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u0432 \u2014 \u0431\u043e\u043b\u044c\u0448\u0430\u044f, \u0442\u044f\u0436\u0435\u043b\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0435\u0439\u0447\u0430\u0441 \u0438\u0434\u0435\u0442 \u0430\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u0445 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u043e\u0431\u044a\u0451\u043c\u0430\u043c\u0438 <em>\u043d\u0435\u043c\u0430\u0440\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445<\/em> \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438 \u2014 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0435\u0442\u0438 \u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p><strong>\u0418\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u0430\u044f \u0441\u0435\u0442\u044c<\/strong> \u2014 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0439 \u0438\u043b\u0438 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u043e\u0433 \u0431\u0438\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438; \u0432 \u0441\u0430\u043c\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435, \u0432 \u0441\u0435\u0442\u0438 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f, \u044d\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u0435 \u0441\u043b\u043e\u0438 \u043d\u0435\u0439\u0440\u043e\u043d\u043e\u0432. \u041f\u0435\u0440\u0432\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u0435\u0439 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0432\u043e\u043f\u043b\u043e\u0449\u0435\u043d\u0438\u0435 \u0435\u0449\u0435 \u0432 60-\u0445 \u0433\u043e\u0434\u0430\u0445 XX \u0432\u0435\u043a\u0430, \u0445\u043e\u0442\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441 \u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u043b\u0435\u0442 \u043f\u044f\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u044c.<\/p>\n<p>  <\/p>\n<p><strong>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430<\/strong> \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u2014 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043e\u0431\u0449\u0438\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u0435\u0451 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f, \u0432\u043e\u0442 <a href=\"https:\/\/www.asimovinstitute.org\/neural-network-zoo\/\" rel=\"nofollow noopener noreferrer\">\u0437\u0434\u0435\u0441\u044c<\/a> \u0435\u0441\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0435\u0435 \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0442\u0435\u043c\u0443, \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0435\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, GAN \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 LSTM.<\/p>\n<p>  <\/p>\n<p><strong>\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435<\/strong> \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u2014 \u0435\u0441\u043b\u0438 \u0432 \u0434\u0432\u0443\u0445 \u0441\u043b\u043e\u0432\u0430\u0445, \u0442\u043e \u044d\u0442\u043e \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0435\u0439\u0440\u043e\u043d\u0430\u043c\u0438. \u041f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c\u0443 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e DALL-E 2, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f\u043c \u0438\u043b\u0438 \u043e\u0431 AlphaGo, \u043e\u0431\u044b\u0433\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u043c \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u0438\u0433\u0440\u043e\u043a\u043e\u0432 \u0432 \u0433\u043e \u2014 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043e\u0431 \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u044f\u0445, \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u043e\u044f\u0432\u0438\u043b\u0438 \u0431\u0435\u0437\u0434\u043d\u0443 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u0441\u0432\u044f\u0437\u0438 \u0431\u044b\u043b\u0438 \u043d\u0430 \u0441\u0432\u043e\u0451\u043c \u043c\u0435\u0441\u0442\u0435. \u0414\u043e\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u2014 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u0430\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0435\u0439\u0440\u043e\u043d\u0430\u043c\u0438 \u043f\u0440\u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0438\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430.<\/p>\n<p>  <\/p>\n<p>\u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u043e \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435? \u0421\u0438\u043b\u044c\u043d\u044b\u0439 \u0418\u0418, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 (\u0441\u043a\u0440\u0435\u0441\u0442\u0438\u043c \u043f\u0430\u043b\u044c\u0446\u044b) \u0440\u0435\u0448\u0430\u0442\u044c \u0432\u0441\u0435 \u043d\u0430\u0448\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0435\u0449\u0435 \u0437\u0430 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u043e\u043c, \u0430 \u043f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0435 \u0441\u0435\u0442\u0438 \u0440\u0435\u0448\u0430\u044e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u043e \u0437\u0443\u0431\u0430\u043c \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c. \u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u00ab\u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e\u00bb \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0448\u0438\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0437\u0430\u0434\u0430\u0447\u0443 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043e\u0442\u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u0441 \u043e\u0434\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439? \u0414\u0430, \u043c\u043e\u0436\u043d\u043e, \u0438 \u0442\u0430\u043a\u0438\u0435 \u043d\u0435\u0431\u0435\u0437\u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0435 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u043d\u0435\u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u043b\u0438\u0441\u044c. \u041d\u043e, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u043f\u0440\u043e\u0440\u044b\u0432 \u0432 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0438 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0431\u0430\u0437\u044b \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f, \u043d\u0430\u043c\u0435\u0442\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 10-15 \u043b\u0435\u0442, \u043f\u043e\u043c\u043d\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043d\u0430 \u0433\u0438\u0433\u0430\u043d\u0442\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u0436\u0435 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432, \u0432\u0440\u043e\u0434\u0435 \u0441\u043c\u0430\u0440\u0442\u0444\u043e\u043d\u043e\u0432, \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435, \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0435\u0439\u0447\u0430\u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0436\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0437\u0430\u0434\u0430\u0447, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438 \u0432\u0438\u0434\u0435\u043e \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u043b\u0438 \u0431\u0435\u0441\u043f\u0438\u043b\u043e\u0442\u043d\u0430\u044f \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430, \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 \u0431\u0430\u0437\u0435 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0437\u0430\u0445\u043e\u0434\u0438\u043b\u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0432\u044f\u043b\u043e\u0442\u0435\u043a\u0443\u0449\u0438\u0445 \u043a\u043e\u043d\u0446\u0435\u043f\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u041c\u0430\u043b\u043e-\u043f\u043e\u043c\u0430\u043b\u0443 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0430\u0448\u0443 \u0436\u0438\u0437\u043d\u044c \u043b\u0443\u0447\u0448\u0435. \u0421\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0430\u0441 \u0441\u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043b\u043e\u0434\u0430\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u0430, \u0445\u043e\u0442\u044c \u043c\u044b \u0438 \u0432\u0435\u043b\u0438\u0447\u0430\u0435\u043c \u0435\u0433\u043e \u00ab\u0441\u043b\u0430\u0431\u044b\u043c\u00bb. \u0418 \u0440\u0435\u0447\u044c \u0438\u0434\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e \u0433\u0440\u043e\u043c\u043a\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445, \u0432\u0440\u043e\u0434\u0435 \u0430\u0432\u0442\u043e\u043f\u0438\u043b\u043e\u0442\u0430 \u00ab\u0422\u0435\u0441\u043b\u044b\u00bb (\u0445\u043e\u0442\u044f \u0438 \u044d\u0442\u043e \u043a\u0440\u0430\u0439\u043d\u0435 \u043d\u0435\u043c\u0430\u043b\u043e\u0432\u0430\u0436\u043d\u043e), \u043d\u043e \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043e \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u043c \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u044d\u043a\u0441\u0430\u0431\u0430\u0439\u0442\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u043c\u044b\u0445 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0439 \u0446\u0438\u0432\u0438\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u2014 \u0432\u0438\u0434\u0435\u043e \u0441 \u0443\u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u0430\u043c\u0435\u0440, \u0441\u043a\u0430\u043d\u043e\u0432 \u041c\u0420\u0422 \u0438 \u041a\u0422, \u0442\u0435\u043b\u0435\u043c\u0435\u0442\u0440\u0438\u0438 \u0441 \u0444\u0438\u0442\u043d\u0435\u0441-\u0431\u0440\u0430\u0441\u043b\u0435\u0442\u043e\u0432, \u043e\u0442\u0447\u0435\u0442\u043e\u0432 \u043e\u0431 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u043b\u0435\u043a\u0430\u0440\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0441\u0440\u0435\u0434\u0441\u0442\u0432 \u0438 \u043f\u0438\u0449\u0435\u0432\u044b\u0445 \u0434\u043e\u0431\u0430\u0432\u043e\u043a. \u0418 \u0435\u0441\u043b\u0438 \u0432\u0441\u0451 \u044d\u0442\u043e \u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0443\u043c\u043d\u044b\u043c\u0438, \u043d\u043e \u0437\u0430\u0442\u043e \u043d\u0435\u0443\u0441\u0442\u0430\u043d\u043d\u044b\u043c\u0438 \u0433\u043b\u0430\u0437\u0430\u043c\u0438 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438, \u0442\u043e \u043a\u0440\u0430\u0442\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u0441\u044f \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0445 \u0434\u0438\u0430\u0433\u043d\u043e\u0437\u043e\u0432, \u043b\u044e\u0434\u0435\u0439, \u0443\u043c\u0435\u0440\u0448\u0438\u0445 \u043e\u0442 \u0438\u043d\u0441\u0443\u043b\u044c\u0442\u043e\u0432 \u0438\u043b\u0438 \u0437\u0430\u043c\u0435\u0440\u0437\u0448\u0438\u0445 \u043d\u0430 \u0443\u043b\u0438\u0446\u0430\u0445, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043b\u0435\u043a\u0430\u0440\u0441\u0442\u0432 \u0441 \u0442\u044f\u0436\u0435\u043b\u044b\u043c\u0438 \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u043c\u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0430\u043c\u0438.<\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u043e\u0434\u043d\u0430\u043a\u043e \u2014 \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u043b\u043d\u044b \u044d\u043d\u0442\u0443\u0437\u0438\u0430\u0437\u043c\u0430 \u0438 \u0433\u043e\u0442\u043e\u0432\u044b \u0445\u043e\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u044b\u0440\u043d\u0443\u0442\u044c \u0432\u043e \u0432\u0441\u0435 \u044d\u0442\u0438 \u043c\u043e\u0434\u043d\u044b\u0435, \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0438 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0432\u0440\u043e\u0434\u0435 \u0431\u0438\u0433\u0434\u0430\u0442\u044b \u0438\u043b\u0438 \u0418\u0418 \u2014 \u0447\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0443\u0433\u043b\u0443\u0431\u043b\u044f\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u0443 \u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0443, \u0442\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u0432 \u0432\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0443\u0447\u0451\u043d\u043e\u0433\u043e, \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430. \u0413\u0434\u0435-\u0442\u043e \u0432 \u0441\u0430\u043c\u043e\u043c \u043a\u043e\u043d\u0446\u0435 \u044d\u0442\u043e\u0433\u043e \u0434\u043b\u0438\u043d\u043d\u043e\u0433\u043e-\u043f\u0440\u0435\u0434\u043b\u0438\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u0430 \u0441\u0438\u0434\u0438\u0442 \u0432\u043e\u0432\u0441\u0435 \u043d\u0435 \u041d\u0435\u043e \u0438\u0437 \u00ab\u041c\u0430\u0442\u0440\u0438\u0446\u044b\u00bb, \u0430 \u044d\u0434\u0430\u043a\u0438\u0439 \u0441\u0435\u0431\u0435 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Grigori_Perelman\" rel=\"nofollow noopener noreferrer\">\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0439 \u041f\u0435\u0440\u0435\u043b\u044c\u043c\u0430\u043d<\/a>, \u0443\u0441\u0442\u0430\u0432\u0448\u0438\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0441 \u0440\u0443\u0447\u043a\u043e\u0439 \u0438 \u043b\u0438\u0441\u0442\u043e\u043c \u0431\u0443\u043c\u0430\u0433\u0438, \u0438\u043d\u043e\u0433\u0434\u0430 \u044d\u0442\u043e\u0439 \u0440\u0443\u0447\u043a\u043e\u0439 \u043d\u0430 \u044d\u0442\u043e\u0439 \u0431\u0443\u043c\u0430\u0433\u0435 \u043f\u0438\u0448\u0443\u0449\u0438\u0439 \u0432\u0435\u0449\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0432\u0430 \u0433\u043e\u0434\u0430 \u0440\u0430\u0437\u0436\u0435\u0432\u044b\u0432\u0430\u0442\u044c \u043b\u0443\u0447\u0448\u0438\u043c \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430\u043c \u043c\u0438\u0440\u0430. \u041a\u0440\u0435\u043f\u043a\u043e \u043f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435, \u043a\u0430\u043a \u0433\u043b\u0443\u0431\u043e\u043a\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0439\u0442\u0438, \u0432\u0437\u0432\u0435\u0441\u044c\u0442\u0435 \u0441\u0432\u043e\u0438 \u0441\u0438\u043b\u044b.<\/p>\n<p>  <\/p>\n<h2 id=\"3-potoki-dannyh\">3. \u041f\u043e\u0442\u043e\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/post_images\/4b1\/afd\/231\/4b1afd231fcd5e11f79e1347cff43e7e.png\" alt=\"Data Flows\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/4b1\/afd\/231\/4b1afd231fcd5e11f79e1347cff43e7e.png\"\/> <\/p>\n<p>  <\/p>\n<h3 id=\"itertools\">Itertools<\/h3>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434\u044b \u043c\u043e\u0434\u0443\u043b\u044f itertools \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 <em>\u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b<\/em>.<\/p>\n<p>  <\/p>\n<p>\u0418\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u2014 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043f\u043e\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u043e\u0431\u0445\u043e\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 next() \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u043d\u0438\u0436\u0435, \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u00ab\u041e\u041e\u041f \/ \u0423\u0442\u0438\u043d\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f\u00bb. \u0412 \u00ab\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0435\u00bb \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u043f\u0435\u0440\u0435\u0433\u043e\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 for, next \u0438\u043b\u0438 list().<\/p>\n<p>  <\/p>\n<p>Itertools \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c\u0438 (\u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 count, cycle \u0438\u043b\u0438 repeat), \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c\u0438 (accumulate, chain, takewhile \u0438 \u0434\u0440\u0443\u0433\u0438\u0435) \u0438 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u043d\u044b\u043c\u0438 (product, combinations, combinations_with_replacement, permutations). \u041b\u0443\u0447\u0448\u0435 \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0438\u0445 \u0432\u0441\u0435, \u0445\u043e\u0442\u044f \u0431\u044b \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u0434\u043a\u043e \u0443\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u043c\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c zip_longest(), \u0438\u043d\u043e\u0433\u0434\u0430 \u0432\u0435\u0441\u044c\u043c\u0430 \u0438 \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u0440\u0438\u0433\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f, \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043b\u043e\u0436\u0430\u0441\u044c \u043d\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c\u0438 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from itertools import count, repeat, cycle  # \u0418\u0442\u0435\u0440\u0430\u0442\u043e\u0440, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f i1 = count(start=0, step=.1) print(next(i1)) print(next(i1)) print(next(i1))  # \u0418\u0442\u0435\u0440\u0430\u0442\u043e\u0440, \u0446\u0438\u043a\u043b\u0438\u0447\u043d\u043e \u0438 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 i2 = cycle([1, 2]) print(next(i2)) print(next(i2)) print(next(i2))  # \u0418\u0442\u0435\u0440\u0430\u0442\u043e\u0440, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043e\u0431\u044a\u0435\u043a\u0442 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 times i3 = repeat(\"Wow!\", times=3) print(list(i3))<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">0 0.1 0.2 1 2 1 ['Wow!', 'Wow!', 'Wow!']<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from itertools import accumulate, chain, compress, dropwhile, takewhile, pairwise import operator  # \u0418\u0442\u0435\u0440\u0430\u0442\u043e\u0440, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u043d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u2014 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435)  i1 = accumulate([1, 2, 3, 4]) i2 = accumulate([1, 2, 3, 4], initial=10) print(list(i1), list(i2))  i3 = accumulate([ -3, -2, -1, 1, 2, 3, 4], operator.mul) print(list(i3))  # \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e def myfunc(accumulated, current):     return accumulated + 2 * current  i4 = accumulate([1, 2, 3, 4], func=myfunc) print(list(i4))  # \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044f\u043c\u0431\u0434\u0443 (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u043d\u0438\u0436\u0435) i5 = accumulate([1, 2, 3, 4], lambda accumulated, current: accumulated + 2 * current) print(list(i5))  # \u0418\u0442\u0435\u0440\u0430\u0442\u043e\u0440, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, # \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0440\u0430\u0432\u043d\u044b\u0439 True \u0438\u043b\u0438 1 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 selectors i6 = compress(\"ABCDEF\", [1, 1, 1, 0, 0, 1]) print(list(i6))  # \u0418\u0442\u0435\u0440\u0430\u0442\u043e\u0440, \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0435\u0441\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0430\u0432\u0435\u043d True. # \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f False, \u0442\u043e \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u043a\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f (\u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f) i7 = dropwhile(lambda x: x&lt;5, [1, 4, 6, 4, 1, 1, 1, 0]) print(list(i7))  # takewhile, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 dropwhile, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, # \u0435\u0441\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0430\u0432\u0435\u043d True i8 = takewhile(lambda x: x&lt;5, [1, 4, 6, 0, 4, 1, 2, 1]) print(list(i8))  # \u0418\u0442\u0435\u0440\u0430\u0442\u043e\u0440, \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 \u043e\u0434\u043d\u0443 \u043e\u0431\u0449\u0443\u044e i2 = chain([\"A\", \"B\", \"C\"],[\"D\", \"E\", \"F\"],[\"G\", \"H\", \"I\"]) print(list(i2)) # \u041a\u0441\u0442\u0430\u0442\u0438, \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0442\u0440\u044e\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 sum(), \u0437\u0430\u0434\u0430\u0432 \u0435\u0439 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 [] (\u0442. \u0435. \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a) a = sum([[\"A\", \"B\", \"C\"],[\"D\", \"E\", \"F\"],[\"G\", \"H\", \"I\"]], []) print(a)  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u043f\u043e\u043f\u0430\u0440\u043d\u043e i6 = pairwise([1, 2, 3, 4, 5]) print(list(i6))<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">[1, 3, 6, 10] [10, 11, 13, 16, 20] [-3, 6, -6, -6, -12, -36, -144] [1, 5, 11, 19] [1, 5, 11, 19] ['A', 'B', 'C', 'F'] [6, 4, 1, 1, 1, 0] [1, 4] ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'] ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'] [(1, 2), (2, 3), (3, 4), (4, 5)]<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u0438\u043a\u0430<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from itertools import product, combinations, combinations_with_replacement, permutations  # \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0435 \u0432\u0441\u0435 \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u044b \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432 a = product(\"abc\", \"xyz\") print(list(a))  b = product([0, 1], repeat=3) print(list(b))  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u0438\u043d\u044b r \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0435\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043d\u0435 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f c = combinations(\"abc\", r=2) print(list(c))  # \u0412\u044b\u0434\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 d = permutations(\"abc\", r=2) print(list(d))  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u0438\u043d\u044b r \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0435\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b e = combinations_with_replacement(\"abc\", r=2) print(list(e))<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">[('a', 'x'), ('a', 'y'), ('a', 'z'), ('b', 'x'), ('b', 'y'), ('b', 'z'), ('c', 'x'), ('c', 'y'), ('c', 'z')] [(0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 1, 1), (1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1)] [('a', 'b'), ('a', 'c'), ('b', 'c')] [('a', 'b'), ('a', 'c'), ('b', 'a'), ('b', 'c'), ('c', 'a'), ('c', 'b')] [('a', 'a'), ('a', 'b'), ('a', 'c'), ('b', 'b'), ('b', 'c'), ('c', 'c')]<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"enumerate\">Enumerate<\/h3>\n<p>  <\/p>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430, \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0446\u0438\u043a\u043b\u0435 for, \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442, \u043d\u043e \u0438 \u0435\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432\u044b\u0439 \u043d\u043e\u043c\u0435\u0440. \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0441\u043e\u0437\u0434\u0430\u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435 \u0446\u0438\u043a\u043b\u0430. \u041e\u0434\u043d\u0430\u043a\u043e, \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430 enumerate, \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u043c \u0432 <a href=\"https:\/\/peps.python.org\/pep-0279\/\" rel=\"nofollow noopener noreferrer\">PEP-279<\/a>. Enumerate \u2014 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0430\u0445\u0430\u0440 (\u00abintroduces\u2026 to simplify a commonly used looping idiom\u00bb), \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0449\u0435 \u0438 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u043c\u0438 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044e. \u041c\u0435\u0442\u043e\u0434 __next__() enumerate \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u0440\u0442\u0435\u0436, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u044d\u0442\u043e\u043c\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u0430 enumerate \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">def enumerate(sequence, start=0):     n = start     for elem in sequence:         yield n, elem         n += 1<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 enumerate \u2014 \u043d\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440, \u0430 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import collections import types  e = enumerate(\"abcdef\") print(isinstance(e, enumerate)) print(isinstance(e, collections.Iterable)) print(isinstance(e, collections.Iterator)) print(isinstance(e, types.GeneratorType))<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">True True True False<\/code><\/pre>\n<p>  <\/p>\n<p>Enumerate \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043d\u0435 \u043d\u0430 Python, \u0430 \u043d\u0430 C, \u0438 \u0432 \u0435\u0433\u043e <a href=\"https:\/\/github.com\/python\/cpython\/blob\/master\/Objects\/enumobject.c#L289\" rel=\"nofollow noopener noreferrer\">\u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435<\/a>, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043d\u0435\u0442 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 yield.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f enumerate:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">values = [\"a\", \"b\", \"c\", \"d\"]  for count, value in enumerate(values):     print(count, value)  print(\"\\n\")  for count, value in enumerate(values, start=10 ):     print(count, value)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">0 a 1 b 2 c 3 d  10 a 11 b 12 c 13 d<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"generator-generator\">\u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 (generator)<\/h3>\n<p>  <\/p>\n<p>\u041b\u044e\u0431\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <em>yield<\/em>, \u0432\u0435\u0440\u043d\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440. \u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430; \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0438\u043b\u0438 \u0431\u0440\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f, \u0444\u0430\u0439\u043b, \u0441\u0435\u0442\u0435\u0432\u043e\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u0442. \u0434.), \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044f \u0438\u0445.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0439\u0442\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0432 \u0446\u0438\u043a\u043b\u0435 \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043d\u043e \u043d\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439. \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0430, \u0442. \u043a. \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 __getitem__().<\/p>\n<p>  <\/p>\n<p>\u0411\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">def count(start, step):     current = start     while True:         yield current         current += step  c = count(100, 10)  print(next(c)) print(next(c)) print(next(c))<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">100 110 120<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440.<br \/>  \u0422\u0430\u043a\u0436\u0435, \u043a\u0430\u043a \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440, \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 list() (\u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0432 list \u0438 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440, \u043d\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0438\u0441\u043a\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0442\u044f\u043d\u0443\u0442\u044c\u0441\u044f :):<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">def count(start, stop, step):     current = start     while current &lt;= stop:         yield current         current += step  c = count(100, 200, 10)  print(next(c)) print(next(c)) print(next(c)) print(list(c))<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">100 110 120 [130, 140, 150, 160, 170, 180, 190, 200]<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b. \u0418\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u2014 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 __next__() \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u0438 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<h4 id=\"obyavlenie-generatora\">\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430<\/h4>\n<p>  <\/p>\n<p>\u041e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043c\u043e\u0436\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438. \u041f\u0435\u0440\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u2014 \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 yield, \u043a\u0430\u043a \u0431\u044b\u043b\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u044b\u0448\u0435.<br \/>  \u0412\u0442\u043e\u0440\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435<\/em> (generator expression):<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">r = range(1, 11) squares = (n**2 for n in r)  print(list(squares))<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0438\u043b\u0438 \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0443 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <em>yield from<\/em>:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">def subg():     yield 'World'  def generator():     yield 'Hello'     yield from subg()     yield '!'  for i in generator():     print(i, end = ' ')<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Hello World ! <\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043e \u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f asyncio \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f yield from \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f <a href=\"https:\/\/docs.python.org\/3.7\/library\/asyncio-task.html#asyncio.coroutine\" rel=\"nofollow noopener noreferrer\">\u043a\u043e\u0440\u0443\u0442\u0438\u043d \u043d\u0430 \u0431\u0430\u0437\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432<\/a>.<\/p>\n<p>  <\/p>\n<h3 id=\"dekoratory\">\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b<\/h3>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b?<\/p>\n<p>  <\/p>\n<p>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0432 \u0448\u0438\u0440\u043e\u043a\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435 \u2013 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u043e\u0434\u0438\u043d \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0434\u0440\u0443\u0433\u043e\u0433\u043e. \u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u2014 \u044d\u0442\u043e, \u043f\u043e \u0441\u0443\u0442\u0438, \u0441\u0432\u043e\u0435\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0435 \u00ab\u043e\u0431\u0451\u0440\u0442\u043a\u0438\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u044e\u0442 \u043d\u0430\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u0434\u043e \u0438\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u044f \u0435\u0451. \u041c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0441\u0430\u0445\u0430\u0440\u043e\u043c \u0434\u043b\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0432\u0438\u0434\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">my_function = my_decorator(my_function)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">def makebold(fn):     def wrapped():         return \"&lt;b>\" + fn() + \"&lt;\/b>\"      return wrapped  def makeitalic(fn):     def wrapped():         return \"&lt;i>\" + fn() + \"&lt;\/i>\"      return wrapped  # \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043f\u0440\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0438\u0433\u0440\u0430\u0435\u0442 \u0440\u043e\u043b\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. @makebold @makeitalic def hello():     return \"Hello, world!\"  print(hello())<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">&lt;b>&lt;i>Hello, world!&lt;\/i>&lt;\/b><\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440, \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import time  def perf_counter(function):     def counted(*args):         start_time = time.perf_counter_ns()         res = function(*args)         print(f\"{time.perf_counter_ns() - start_time} ns\")         return res      return counted  @perf_counter def slow_sum(x, y):     time.sleep(1)     return x + y  print(slow_sum(1, 2))<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">1002478400 ns 3<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"lru-cache\">LRU Cache<\/h3>\n<p>  <\/p>\n<p>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440, \u043a\u0435\u0448\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439. \u0412\u0441\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0445\u044d\u0448\u0438\u0440\u0443\u0435\u043c\u044b.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import functools  def recursion_sum(n):     if n == 1:         return n     print(n, end=\" \")     return n + recursion_sum(n - 1)  recursion_sum(5) print(\"\\n\") recursion_sum(9) print(\"\\n\")  @functools.lru_cache def recursion_sum2(n):     if n == 1:         return n     print(n, end=\" \")     return n + recursion_sum2(n - 1)  recursion_sum2(5) print(\"\\n\") recursion_sum2(9)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">5 4 3 2   9 8 7 6 5 4 3 2   5 4 3 2   9 8 7 6   45<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u0435\u0448\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e 128 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 &#8216;maxsize=None&#8217;.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043a\u0430 \u043c\u044b \u043d\u0435 \u0443\u0448\u043b\u0438 \u0434\u0430\u043b\u0435\u043a\u043e \u043e\u0442 \u0442\u0435\u043c\u0430 \u043a\u0435\u0448\u0430, \u043f\u043e\u0433\u0443\u0433\u043b\u0438\u0442\u0435 \u0437\u0430\u043e\u0434\u043d\u043e \u043c\u043e\u0434\u0443\u043b\u044c weakref \u0438 WeakValueDictionary, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043a\u0435\u0448\u0435\u043c.<\/p>\n<p>  <\/p>\n<h3 id=\"parametrizovannyy-dekorator\">\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440<\/h3>\n<p>  <\/p>\n<p>\u0412 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0435, \u0438 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u2014 args \u0438 kwargs \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u2014 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u0440\u0443\u0433\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">def text_wrapper(wrap_text):     def wrapped(function):         def wrapper(*args, **kwargs):             result = function(*args, **kwargs)             return f\"{wrap_text}\\n{result}\\n{wrap_text}\"          return wrapper      return wrapped  @text_wrapper('============') def my_decorated_function(text):     return text  print(my_decorated_function('Hello, world!'))<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">============ Hello, world! ============<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"kontekstnyy-menedzher\">\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u0439 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440<\/h3>\n<p>  <\/p>\n<p>\u041a\u043e\u0434, \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u043d\u044b\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 with \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e: \u043a\u0430\u043a \u0434\u043e, \u0442\u0430\u043a \u0438 \u043f\u043e\u0441\u043b\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432\u0445\u043e\u0434\u0430 \u0432 \u0431\u043b\u043e\u043a with \u0438 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u043d\u0435\u0433\u043e. \u041e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043b\u043e\u0433\u0438\u043a\u0443 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u043c \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u043c.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 __enter__ \u0438 __exit__.<br \/>  __enter__ \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0432 \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0433\u0434\u0430 \u0445\u043e\u0434 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u0432\u043d\u0443\u0442\u0440\u044c with. \u041c\u0435\u0442\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u041e\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u043c\u0443 \u0432\u043d\u0443\u0442\u0440\u0438 \u0431\u043b\u043e\u043a\u0430 with \u043a\u043e\u0434\u0443.<br \/>  __exit__ \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u044b\u0445\u043e\u0434\u0430 \u0431\u043b\u043e\u043a\u0430, \u0432 \u0442.\u0447. \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u0430 \u0442\u0440\u043e\u0439\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (exc_class, exc_instance, traceback).<\/p>\n<p>  <\/p>\n<p>\u0421\u0430\u043c\u044b\u0439 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u0439 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u2013 \u043a\u043b\u0430\u0441\u0441, \u043f\u043e\u0440\u043e\u0436\u0434\u0435\u043d\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 open. \u041e\u043d \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0444\u0430\u0439\u043b \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043a\u0440\u044b\u0442 \u0434\u0430\u0436\u0435 \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0431\u043b\u043e\u043a\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430.<\/p>\n<p>  <\/p>\n<p>\u0416\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0432\u044b\u0445\u043e\u0434\u0438\u0442\u044c \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u0433\u043e \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430, \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u044b.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">with open('file.txt') as f:     data = f.read()  process_data(data)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435 \u043c\u044b \u0432\u044b\u0448\u043b\u0438 \u0438\u0437 \u0431\u043b\u043e\u043a\u0430 with \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0431\u043b\u043e\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.<\/p>\n<p>  <\/p>\n<p>\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u0435 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u043c\u0435\u043d\u044b \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439 \u0411\u0414.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u0439 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0411\u0414 SQLite:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import sqlite3  class db_conn:      def __init__(self, db_name):         self.db_name = db_name      # \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0411\u0414     def __enter__(self):         self.conn = sqlite3.connect(self.db_name)         return self.conn      # \u0417\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0411\u0414     def __exit__(self, exc_type, exc_value, exc_traceback):         self.conn.close()         if exc_value:             raise  if __name__ == \"__main__\":     db = \"test_context_connect.db\"      with db_conn(db) as conn:         cursor = conn.cursor()<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"kontekstnyy-menedzher-na-baze-contextlib\">\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u0439 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u043d\u0430 \u0431\u0430\u0437\u0435 contextlib<\/h3>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0448 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u0439 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0411\u0414 SQLite \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 contextlib:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import sqlite3 from contextlib import contextmanager  # \u0421\u0445\u0435\u043c\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f: \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0434\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 yield - \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 __enter__, # \u0432\u0441\u0451 \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u2013 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 __exit__. @contextmanager def db_conn(db_name):     # \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0411\u0414     conn = sqlite3.connect(db_name)      yield conn      # \u0417\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0411\u0414     conn.close()  if __name__ == \"__main__\":     db = \"test_contextlib_connect.db\"      with db_conn(db) as conn:         cursor = conn.cursor()<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"4-oop\">4. \u041e\u041e\u041f<\/h2>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/post_images\/7ec\/81b\/9a6\/7ec81b9a69c879e5ff97b2f1a10ad093.png\" alt=\"OOP\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/7ec\/81b\/9a6\/7ec81b9a69c879e5ff97b2f1a10ad093.png\"\/> <\/p>\n<p>  <\/p>\n<h3 id=\"klassy-i-obekty\">\u041a\u043b\u0430\u0441\u0441\u044b \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b<\/h3>\n<p>  <\/p>\n<p>\u0422\u0443\u0442, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0431\u044b\u043b\u043e \u0431\u044b \u043a \u043c\u0435\u0441\u0442\u0443 \u043a\u0440\u0430\u0442\u0435\u043d\u044c\u043a\u043e\u0435, \u043c\u0438\u043d\u0443\u0442 \u043d\u0430 \u0441\u043e\u0440\u043e\u043a, \u0432\u0432\u0435\u0434\u0435\u043d\u044c\u0438\u0446\u0435 \u0432 \u0442\u0435\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043d\u043e \u0432 \u043d\u0430\u0448 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0442\u0430\u043a\u0430\u044f \u043c\u043e\u0449\u043d\u0430\u044f \u0432\u0440\u0435\u0437\u043a\u0430 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0443\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f. \u041e\u0431\u044a\u044f\u0441\u043d\u044e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043d\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0438\u0437 \u043a\u0438\u043d\u043e\u0432\u0441\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u00ab\u0427\u0443\u0436\u0438\u0445\u00bb:<br \/>  \u043e\u0431\u044a\u0435\u043a\u0442 \u2014 \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043a\u0441\u0435\u043d\u043e\u043c\u043e\u0440\u0444;<br \/>  \u043a\u043b\u0430\u0441\u0441 \u2014 \u044d\u0442\u043e \u041a\u043e\u0440\u043e\u043b\u0435\u0432\u0430 \u043a\u0441\u0435\u043d\u043e\u043c\u043e\u0440\u0444\u043e\u0432. \u041a\u043b\u0430\u0441\u0441 \u043b\u0438\u0431\u043e \u0440\u043e\u0436\u0430\u0435\u0442 \u043a\u0441\u0435\u043d\u043e\u043c\u043e\u0440\u0444\u0430, \u043b\u0438\u0431\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u0432 \u0431\u043e\u0439 \u0441\u0430\u043c (@staticmethod);<br \/>  \u043c\u0435\u0442\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u0442\u0430\u043a\u0430\u044f \u0421\u0443\u043f\u0435\u0440-\u041a\u043e\u0440\u043e\u043b\u0435\u0432\u0430, \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0441 \u00ab\u0421\u0443\u043b\u0430\u043a\u043e\u00bb, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u043e\u0436\u0430\u0435\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u041a\u043e\u0440\u043e\u043b\u0435\u0432;<br \/>  \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u043a\u0441\u0435\u043d\u043e\u043c\u043e\u0440\u0444 \u0438\u0437 \u00ab\u0412\u043e\u0441\u043a\u0440\u0435\u0448\u0435\u043d\u0438\u044f\u00bb, \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u043c\u0438\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0442\u0430\u043a\u043e\u0439, \u0432\u0437\u044f\u0432\u0448\u0438\u0439 \u043b\u0443\u0447\u0448\u0435\u0435 \u0438 \u043e\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0433\u0435\u043d\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438 \u043e\u0442 \u0433\u0435\u043d\u043e\u0432 \u0420\u0438\u043f\u043b\u0438. <\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u0442\u0435\u043c\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0441 \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u0437\u0436\u0435, \u0432 \u0433\u043b\u0430\u0432\u0435 \u00ab\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430\u00bb, \u043d\u043e, \u0432\u043e\u043e\u0431\u0449\u0435, \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u043e\u0441\u043e\u0431\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e; \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e \u043d\u0435\u0433\u043e \u043b\u0443\u0447\u0448\u0435 \u0434\u043e\u0439\u0442\u0438, \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0433\u0440\u044f\u0437\u043d\u0443\u0432 \u0432 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0441\u0442\u043e\u0438\u0442 \u0432\u044b\u0431\u043e\u0440 \u2014 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043b\u0435\u0447\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u0443\u0441\u043e\u043a \u043a\u043e\u0434\u0430 \u0438\u043b\u0438 \u0443\u0436\u0435 \u0443\u0441\u044b\u043f\u0438\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0441\u0451 \u043f\u043e \u043d\u043e\u0432\u043e\u0439? \u041a\u043e\u0433\u0434\u0430-\u0442\u043e \u0434\u0430\u0432\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u044f \u043f\u0438\u0441\u0430\u043b \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435 \u0434\u043b\u044f \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432, \u0442\u043e \u0447\u0438\u0442\u0430\u044f \u0421\u0442\u0440\u0430\u0443\u0441\u0442\u0440\u0443\u043f\u0430, \u0441\u043b\u0435\u0433\u043a\u0430 \u043d\u0435\u0434\u043e\u0443\u043c\u0435\u0432\u0430\u043b \u2014 \u0437\u0430\u0447\u0435\u043c \u0432\u0441\u0451 \u044d\u0442\u043e? \u0427\u0442\u043e\u0431\u044b \u043e\u0441\u043e\u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u0432 \u043e\u0431\u0443\u0432\u0438, \u043d\u0430\u0434\u043e \u043f\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0431\u043e\u0441\u0438\u043a\u043e\u043c.<\/p>\n<p>  <\/p>\n<h3 id=\"magicheskie-metody\">\u041c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b<\/h3>\n<p>  <\/p>\n<p>\u0421\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 (\u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0442\u0430\u043a\u0436\u0435 magic \u0438\u043b\u0438 dunder) \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430 \u2014 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u043a\u043b\u0430\u0441\u0441\u0430\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044e \u043a \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u043c \u044f\u0437\u044b\u043a\u0430.<br \/>  \u041c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043d\u0438 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043f\u043e\u0447\u0442\u0438 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u044f\u0432\u043d\u043e. \u0418\u0445 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043b\u0438 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0444\u0443\u043d\u043a\u0446\u0438\u044f len() \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 __len__() \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u041c\u0435\u0442\u043e\u0434 __add__(self, other) \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0438 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c +.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<p>  <\/p>\n<p>__init__: \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430<br \/>  __add__: \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c<br \/>  __eq__: \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e \u0441 \u0434\u0440\u0443\u0433\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c<br \/>  __cmp__: \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 (\u0431\u043e\u043b\u044c\u0448\u0435, \u043c\u0435\u043d\u044c\u0448\u0435, \u0440\u0430\u0432\u043d\u043e)<br \/>  __iter__: \u043f\u0440\u0438 \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u0446\u0438\u043a\u043b <\/p>\n<p>  <\/p>\n<pre><code class=\"python\">print(dir(int), \"\\n\")  class A:  # An empty class     ...  a = A() print(dir(a), \"\\n\") print(repr(a), \"\\n\") print(str(a))<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getnewargs__', '__gt__', '__hash__', '__index__', '__init__', '__init_subclass__', '__int__', '__invert__', '__le__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'as_integer_ratio', 'bit_count', 'bit_length', 'conjugate', 'denominator', 'from_bytes', 'imag', 'numerator', 'real', 'to_bytes']   ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__']   &lt;__main__.A object at 0x000001A1FFF3AF20>   &lt;__main__.A object at 0x000001A1FFF3AF20><\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 __init__ \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0438\u0447\u0435\u0433\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c. \u041f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.<br \/>  __repr__ (representation) \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435-\u043c\u0435\u043d\u0435\u0435 \u043c\u0430\u0448\u0438\u043d\u043e-\u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435 \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438.<br \/>  <em>\u0418\u043d\u043e\u0433\u0434\u0430<\/em> repr \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<br \/>  __str__ \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e-\u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435. \u0415\u0441\u043b\u0438 __str__ \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d, \u0442\u043e str \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 repr. <\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class Person:  # A simple class with init, repr and str methods     def __init__(self, name: str):         self.name: str = name      def __repr__(self):         return f\"Person '{self.name}'\"      def __str__(self):         return f\"{self.name}\"      def say_hi(self):         print(\"Hi, my name is\", self.name)  p = Person(\"Charlie\") p.say_hi() print(repr(p)) print(str(p))<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Hi, my name is Charlie Person 'Charlie' Charlie<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"property\">@property<\/h3>\n<p>  <\/p>\n<p>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 <a href=\"https:\/\/docs.python.org\/3\/library\/functions.html?highlight=property#property\" rel=\"nofollow noopener noreferrer\">@property<\/a> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043a\u0430\u043a \u043f\u043e\u043b\u044f. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0447\u0442\u0435\u043d\u0438\u044f\/\u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u043e\u043b\u044f \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u043c\u0438\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import math  class Circle:     def __init__(self, radius, max_radius):         self._radius = radius         self.max_radius = max_radius      @property     def radius(self):         return self._radius      @radius.setter     def radius(self, value):         if value &lt;= self.max_radius:             self._radius = value         else:             raise ValueError      @property     def area(self):         return 2 * self.radius * math.pi  circle = Circle(10, 100) circle.radius = 20  # OK # circle.radius = 101  # Raises ValueError print(circle.area)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">125.66370614359172<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"staticmethod\">@staticmethod<\/h3>\n<p>  <\/p>\n<p>\u041e\u0431\u044b\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 (\u0442. \u0435. \u043d\u0435 \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438 @staticmethod \u0438\u043b\u0438 @classmethod) \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430. <\/p>\n<p>  <\/p>\n<p>@staticmethod \u2014 \u043c\u0435\u0442\u043e\u0434, \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0449\u0438\u0439 \u043a\u043b\u0430\u0441\u0441\u0443, \u0430 \u043d\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0443 \u043a\u043b\u0430\u0441\u0441\u0430. \u041c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0431\u0435\u0437 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430, \u0442. \u043a. \u043c\u0435\u0442\u043e\u0434 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430. \u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 @staticmethod \u043f\u043e\u043c\u0435\u0447\u0430\u044e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441 \u043a\u043b\u0430\u0441\u0441\u043e\u043c, \u043d\u043e \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430.<\/p>\n<p>  <\/p>\n<h3 id=\"classmethod-cls-self\">@classmethod, cls, self<\/h3>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 (\u043a\u0430\u043a @staticmethod), \u043d\u043e \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0434\u0440\u0443\u0433\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u0430\u043c \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u0430, \u0442\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c @classmethod.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class B(object):     def foo(self, x):         print(f\"Run foo({self}, {x})\")      @classmethod     def class_foo(cls, x):         print(f\"Run class_foo({cls}, {x})\")      @staticmethod     def static_foo(x):         print(f\"Run static_foo({x})\")  b = B() b.foo(1) b.class_foo(1) b.static_foo(1)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Run foo(&lt;__main__.B object at 0x000001A1FFF3A980>, 1) Run class_foo(&lt;class '__main__.B'>, 1) Run static_foo(1)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0423 @classmethod \u043f\u0435\u0440\u0432\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c cls (\u043a\u043b\u0430\u0441\u0441), \u0430 \u0443 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u2014 self (\u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430).<br \/>  \u0414\u043b\u044f @staticmethod \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0438 cls, \u043d\u0438 self.<\/p>\n<p>  <\/p>\n<h3 id=\"__dict__\">__dict__<\/h3>\n<p>  <\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u043c\u0435\u0435\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 __dict__. \u042d\u0442\u043e \u00ab\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439\u00bb, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u043e\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442, \u0435\u0433\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e. __dict__ \u2014 \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u0440\u0430\u043d\u0438\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b, \u0438 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043a\u043b\u044e\u0447\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <em>\u0438\u043c\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430<\/em>, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, <em>\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430<\/em>.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class Supercriminal:     publisher = 'DC Comics'  Riddler = Supercriminal() print(Supercriminal.__dict__) print(Riddler.__dict__)  Riddler.name = 'Edward Nygma' print(Riddler.__dict__)  # Values from object __dict__  print(Riddler.publisher)  # Value from class __dict__<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">{'__module__': '__main__', 'publisher': 'DC Comics', '__dict__': &lt;attribute '__dict__' of 'Supercriminal' objects>, '__weakref__': &lt;attribute '__weakref__' of 'Supercriminal' objects>, '__doc__': None} {} {'name': 'Edward Nygma'} DC Comics<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 Python \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u044b\u0441\u043a\u0438\u0432\u0430\u0435\u0442 \u0441\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043b\u0430\u0441\u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u043a\u043b\u0430\u0441\u0441\u044b, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443\u043d\u0430\u0441\u0430\u043b\u0435\u0434\u043e\u0432\u0430\u043d \u043a\u043b\u0430\u0441\u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<p>  <\/p>\n<h3 id=\"__slots__\">__slots__<\/h3>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u0440\u0438\u043f\u043e\u043c\u043d\u0438\u0442\u0435 \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0438 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u0435\u0436\u0434\u0443 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u0438 \u0438\u0438\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c, \u0442\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u0435, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0438 Python \u043f\u044b\u0442\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0432\u044b\u0431\u043e\u0440 \u043c\u0435\u0436\u0434\u0443 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e\u043c \u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e (\u0442\u0443\u0442 \u0421\u0438 \u0441 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u043c\u0438 \u0432\u0441\u0442\u0430\u0432\u043a\u0430\u043c\u0438 \u0441\u043b\u0435\u0433\u043a\u0430 \u043d\u0430\u043f\u0440\u044f\u0433\u0430\u0435\u0442\u0441\u044f, \u043d\u043e \u043f\u043e\u0442\u043e\u043c \u043e\u043f\u0430\u0434\u0430\u0435\u0442, \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u0445\u043e\u0442\u0435\u043b \u0447\u0442\u043e-\u0442\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043d\u043e \u0431\u043b\u0430\u0433\u043e\u0440\u0430\u0437\u0443\u043c\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0443\u043c\u0430\u043b). \u041a \u0441\u043f\u0438\u0441\u043a\u0443 \u0442\u0430\u043a\u0438\u0445 \u0436\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u044f\u0437\u044b\u043a\u0430, \u0437\u0430\u0442\u043e\u0447\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u0438 __slots__.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 <a href=\"https:\/\/docs.python.org\/3\/reference\/datamodel.html?highlight=slots#object.__slots__\" rel=\"nofollow noopener noreferrer\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f<\/a> \u043f\u043e __slots__, \u0430 \u0432\u043e\u0442 <a href=\"https:\/\/stackoverflow.com\/questions\/472000\/usage-of-slots\/28059785#28059785\" rel=\"nofollow noopener noreferrer\">\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0430\u0437\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f<\/a> \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438. \u041f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u00abslots \u0438\u043b\u0438 \u043d\u0435 slots\u00bb \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 <a href=\"https:\/\/peps.python.org\/pep-0412\/\" rel=\"nofollow noopener noreferrer\">PEP 412 \u2013 Key-Sharing Dictionary<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043d\u0451\u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437\u0434\u0440\u0430\u0439 \u0432 \u043d\u0435\u043a\u043e\u0433\u0434\u0430 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043a __slots__.<\/p>\n<p>  <\/p>\n<p>__dict__, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0439 \u0447\u0443\u0442\u044c \u0432\u044b\u0448\u0435 \u2013 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430 \u043b\u0435\u0442\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u044f \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u0430, \u0447\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u043d\u043e \u043f\u043e\u0440\u043e\u0439 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0430\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0441\u043e\u0437\u0434\u0430\u0432 __slots__ \u2014 \u0436\u0435\u0441\u0442\u043a\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u0435\u0434\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432, \u0440\u0435\u0437\u0435\u0440\u0432\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043f\u0430\u043c\u044f\u0442\u044c, \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e <em>\u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u0442 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 __dict__ \u0438 __weakref__<\/em>. \u0421\u043b\u043e\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0435\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 ORM, \u043b\u0438\u0431\u043e \u043a\u043e\u0433\u0434\u0430 \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u043f\u0438\u0441\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u043f\u043e\u0438\u0441\u043a \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class Clan:     __slots__ = [\"first\", \"second\"]  clan = Clan() clan.first = \"Joker\" clan.second = \"Lex Luthor\" # clan.third = \"Green Goblin\"  # Raises AttributeError # print(clan.__dict__)  # Raises AttributeError<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043b\u043e\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f, \u0441\u043a\u0430\u0436\u0435\u043c, \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0445 requests (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, __slots__ = [&#171;url&#187;, &#171;netloc&#187;, &#171;simple_url&#187;, &#171;pypi_url&#187;, &#171;file_storage<em>domain&#187;]) \u0438\u043b\u0438 ORM peewee (__slots_\\<\/em> = (&#8216;stack&#8217;, &#8216;_sql&#8217;, &#8216;_values&#8217;, &#8216;alias_manager&#8217;, &#8216;state&#8217;)).<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 __slots__ \u0438\u043c\u0435\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0443 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u043d\u0438\u0436\u0435.<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043e \u043a\u0430\u043a\u043e\u043c \u043f\u0440\u0438\u0440\u043e\u0441\u0442\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438 \u0438\u0434\u0451\u0442 \u0440\u0435\u0447\u044c, \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import timeit import pympler.asizeof  # \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 sys.getsizeof - \u043d\u0435 \u043b\u0443\u0447\u0448\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0431\u0435\u0440\u0435\u043c \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435  class NotSlotted():     pass  class Slotted():     __slots__ = 'foo'  not_slotted = NotSlotted() slotted = Slotted()  def get_set_delete_fn(obj):     def get_set_delete():         obj.foo = \"Never Ending Song of Love\"         del obj.foo      return get_set_delete  ns = min(timeit.repeat(get_set_delete_fn(not_slotted))) s = min((timeit.repeat(get_set_delete_fn(slotted))))  print(ns, s, f'{(ns - s) \/ s * 100} %')  print(pympler.asizeof.asizeof(not_slotted), 'bytes') print(pympler.asizeof.asizeof(slotted), 'bytes')<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">0.10838449979200959 0.08712740009650588 24.39772066187959 % 280 bytes 40 bytes<\/code><\/pre>\n<p>  <\/p>\n<p>\u042f \u0432 Python 3.10 \u0432 Windows \u0432\u0438\u0436\u0443 24 % \u0440\u0430\u0437\u043d\u0438\u0446\u044b.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e \u0435\u0449\u0435 \u0440\u0430\u0437 \u2014 \u043f\u0440\u043e\u0433\u043d\u044f\u0439\u0442\u0435 \u0432\u0441\u0435 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430 \u0432 IDE, \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0438 \u043d\u0443\u0436\u043d\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0432\u0438\u0434\u043e\u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0441 __dict__ \u0438 __slots__. \u0410 \u0437\u0430\u043e\u0434\u043d\u043e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0438\u0441\u043f\u044b\u0442\u0430\u0439\u0442\u0435 \u0434\u0430\u0432\u043d\u043e \u043d\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044e\u0449\u0438\u0439\u0441\u044f, \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u0432 Python 3.10 <a href=\"https:\/\/docs.python.org\/3\/library\/dataclasses.html#module-contents\" rel=\"nofollow noopener noreferrer\">\u0441\u0438\u043c\u0431\u0438\u043e\u0437<\/a> \u043c\u0435\u0436\u0434\u0443 __slots__ \u0438 dataclass.<\/p>\n<p>  <\/p>\n<h3 id=\"utinaya-tipizaciya\">\u0423\u0442\u0438\u043d\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f<\/h3>\n<p>  <\/p>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Duck_typing\" rel=\"nofollow noopener noreferrer\">\u0423\u0442\u0438\u043d\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f<\/a> (duck types) \u2014 \u043f\u043e\u0441\u0442\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u044f\u0432\u043d\u043e\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435, \u0430 \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430. \u0422\u0430\u043a, \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434\u044b __next__() \u0438 __iter__(), \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u044f\u0432\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f (\u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0432\u0440\u043e\u0434\u0435 <a href=\"https:\/\/habr.com\/ru\/users\/iterator\/\" class=\"user_link\">iterator<\/a>) \u0438\u043b\u0438, \u0441\u043a\u0430\u0436\u0435\u043c, \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 Iterator.<\/p>\n<p>  <\/p>\n<h3 id=\"iterator\">Iterator<\/h3>\n<p>  <\/p>\n<p>\u0418\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u2014 \u043a\u043b\u0430\u0441\u0441, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434\u044b __next__() \u0438 __iter__().<br \/>  \u041c\u0435\u0442\u043e\u0434 __next__() \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0438\u043b\u0438 \u0432\u044b\u043a\u0438\u0434\u044b\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 StopIteration, \u0447\u0442\u043e\u0431\u044b \u0441\u0438\u0433\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u0438\u0441\u0447\u0435\u0440\u043f\u0430\u043b \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<br \/>  \u041c\u0435\u0442\u043e\u0434 __iter__() \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c &#171;self&#187;.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class LimitCounter:     def __init__(self, max_value: int):         self.count = 0         self.max_value = max_value      def __next__(self):         self.count += 1          if self.count &lt;= self.max_value:             return self.count         else:             raise StopIteration      def __iter__(self):         return self  limit_counter = LimitCounter(2) print(next(limit_counter)) print(next(limit_counter))  # print(next(limit_counter))  # Raises StopIteration<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">1 2<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"comparable\">Comparable<\/h3>\n<p>  <\/p>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Python 3.4, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043c\u0435\u0442\u043e\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b __lt__ (\u043c\u0435\u043d\u044c\u0448\u0435) \u0438 __eq__ (\u0440\u0430\u0432\u043d\u043e), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 @functools.total_ordering.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from functools import total_ordering  @total_ordering class Person:     def __init__(self, firstname: str, lastname: str):         self.firstname: str = firstname         self.lastname: str = lastname      def _is_valid_operand(self, other):         return hasattr(other, \"lastname\") and hasattr(other, \"firstname\")      def __eq__(self, other):         if not self._is_valid_operand(other):             return NotImplemented         return (self.lastname, self.firstname) == (other.lastname, other.firstname)      def __lt__(self, other):         if not self._is_valid_operand(other):             return NotImplemented         return (self.lastname, self.firstname) &lt; (other.lastname, other.firstname)  Finn = Person(\"Finn\", \"the Human\") Jake = Person(\"Jake\", \"the Dog\")  print(Finn != Jake)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">True<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"hashable\">Hashable<\/h3>\n<p>  <\/p>\n<p>\u0425\u0435\u0448\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b __hash__() \u0438 __eq__(). \u0425\u0435\u0448 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u0435\u043d \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430. \u0425\u0435\u0448\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u043a\u043b\u044e\u0447\u0438 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044f\u0445 \u0438 \u043a\u0430\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u043b\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <\/p>\n<p>Hashable objects that compare equal must have the same hash value, meaning default hash() that returns <code>'id(self)'<\/code> will not do. That is why Python automatically makes classes unhashable if you only implement eq().<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class Hero:     def __init__(self, name: str, level: int):         self.name: str = name         self.level: int = level      def _is_valid_operand(self, other):         return hasattr(other, \"name\") and hasattr(other, \"level\")      def __eq__(self, other):         if not self._is_valid_operand(other):             return NotImplemented         return (self.name, self.level) == (other.name, other.level)      def __hash__(self):         return hash((self.name, self.level))  Finn = Hero(\"Finn the Human\", 10_000) Jake = Hero(\"Jake the Dog\", 10_000)  print(hash(Finn)) print(hash(Jake))<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">-8707075988359731747 -2276052447712954388<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"sortable\">Sortable<\/h3>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044f\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0442\u0430\u043a\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u0430\u043a sort() \u0438\u043b\u0438 max() \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u043a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 Comparable, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b __lt__ (\u043c\u0435\u043d\u044c\u0448\u0435) \u0438 __eq__ (\u0440\u0430\u0432\u043d\u043e), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 @functools.total_ordering.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u043c\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f (__lt()__, __gt()__, __le__() \u0438 __ge__()).<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u043f\u043e \u0438\u043c\u0435\u043d\u0438, \u0430 \u043f\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u043c\u0443 \u0431\u0430\u043b\u043b\u0443.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from functools import total_ordering from statistics import mean  @total_ordering class Student:     def __init__(self, name: str, grades: list[int]):         self.name: str = name         self.grades: list[int] = grades      def _is_valid_operand(self, other):         return hasattr(other, \"name\") and hasattr(other, \"grades\")      def __eq__(self, other):         if not self._is_valid_operand(other):             return NotImplemented         return mean(self.grades) == mean(other.grades)      def __lt__(self, other):         if not self._is_valid_operand(other):             return NotImplemented         return mean(self.grades) &lt; mean(other.grades)      # \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c str \u0434\u043b\u044f \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e-\u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0439 \u0440\u0435\u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430     def __str__(self):         return self.name + \" \" + str(mean(self.grades))  Melissa = Student(\"Melissa Andrew\", [4, 3, 4, 5, 4]) Peter = Student(\"Peter Shining Jr.\", [3, 3, 4, 5, 3]) Joe = Student(\"Just Joe\", [5, 5, 4, 5, 5])  print([str(stud) for stud in sorted([Peter, Melissa, Joe], reverse=True)])<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">['Just Joe 4.8', 'Melissa Andrew 4', 'Peter Shining Jr. 3.6']<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"callable\">Callable<\/h3>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0437\u043e\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 __call__. \u0422\u0438\u043f\u044b, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0445 \u0432\u044b\u0437\u043e\u0432\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043d\u0430\u0431\u043e\u0440 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class Counter:     def __init__(self):         self.i = 0     def __call__(self):         self.i += 1         return self.i  counter = Counter()  print(counter()) print(counter()) print(counter())<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">1 2 3<\/code><\/pre>\n<p>  <\/p>\n<p>@classmethod \u043d\u0435\u043b\u044c\u0437\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class Check():     @classmethod      def class_method(cls):         pass       @staticmethod     def static_method():         pass      def instance_method(self):         pass   for attr, val in vars(Check).items():     if not attr.startswith(\"__\"):         print (attr, f\"{'is' if callable(val) else 'is NOT'} callable\")<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">class_method is NOT callable static_method is callable instance_method is callable<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u0435 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u044b, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0433\u043b\u0430\u0432\u0435, \u0442\u043e\u0436\u0435, \u043a\u0430\u043a \u043c\u044b \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0438\u0434\u0438\u043c, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0443\u0442\u0438\u043d\u0443\u044e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 __enter__ \u0438 __exit__.<\/p>\n<p>  <\/p>\n<h3 id=\"utinaya-tipizaciya-iteriruemyh-obektov\">\u0423\u0442\u0438\u043d\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432<\/h3>\n<p>  <\/p>\n<h3 id=\"iterable\">Iterable<\/h3>\n<p>  <\/p>\n<p><a href=\"https:\/\/docs.python.org\/3\/library\/collections.abc.html#collections.abc.Iterable\" rel=\"nofollow noopener noreferrer\">Iterable<\/a> \u2014 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043e\u0447\u0435\u0440\u0451\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u043f\u043e \u0432\u0441\u0435\u043c \u0441\u0432\u043e\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 __iter__(), \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440. \u0423 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c __iter__() \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 __contains__().<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class MyIterable:     def __init__(self, *args):         self.a = list(args)      def __iter__(self):         return iter(self.a)  mi = MyIterable(1, 2, 3, 4) print([el for el in mi]) print(1 in mi)  # __contains__()<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">[1, 2, 3, 4] True<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"collection\">Collection<\/h3>\n<p>  <\/p>\n<p><a href=\"https:\/\/docs.python.org\/3\/library\/collections.abc.html#collections.abc.Collection\" rel=\"nofollow noopener noreferrer\">Collection<\/a> \u2014 \u043e\u0431\u044a\u0435\u043a\u0442, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043e\u0447\u0435\u0440\u0451\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u043f\u043e \u0432\u0441\u0435\u043c \u0441\u0432\u043e\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0438 \u043e\u0431\u043b\u0430\u0434\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c.<br \/>  \u0412 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a iter() \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043c\u0435\u0442\u043e\u0434 len(), \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class MyCollection:     def __init__(self, *args):         self.a = list(args)      def __iter__(self):         return iter(self.a)      def __len__(self):         return len(self.a)  mc = MyCollection(1, 2, 3, 4) print([el for el in mc]) print(1 in mc) print(len(mc))<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">[1, 2, 3, 4] True 4<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"sequence\">Sequence<\/h3>\n<p>  <\/p>\n<p>\u0422\u0440\u0435\u0431\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u044b len() and getitem(). getitem() \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c \u0438\u043b\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 IndexError.<br \/>  \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0440\u043e\u0436\u0434\u0435\u043d\u044b \u043c\u0435\u0442\u043e\u0434\u044b iter(), reversed() \u0438 contains().<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class MySequence:     def __init__(self, a):         self.a = a     def __len__(self):         return len(self.a)     def __getitem__(self, i):         return self.a[i]<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"abc-sequence\">ABC Sequence<\/h3>\n<p>  <\/p>\n<p>\u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f Sequence \u0438\u0437 <a href=\"https:\/\/docs.python.org\/3\/library\/collections.abc.html\" rel=\"nofollow noopener noreferrer\">Abstract Base Classes for Containers<\/a> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 Sequence.<br \/>  \u0412\u0441\u0451 \u0442\u0430\u043a \u0436\u0435 \u0442\u0440\u0435\u0431\u0443\u044f __getitem__ \u0438 __len__, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 __contains_<em>, __iter__, __reversed_\\<\/em>, index \u0438 count.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from collections import abc  class MyAbcSequence(abc.Sequence):     def __init__(self, a):         self.a = a     def __len__(self):         return len(self.a)     def __getitem__(self, i):         return self.a[i]<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"tablica-trebuemyh-i-dostupnyh-metodov\">\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0445 \u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432:<\/h3>\n<p>  <\/p>\n<pre><code class=\"plaintext\">+------------+------------+------------+------------+--------------+ |            |  Iterable  | Collection |  Sequence  | ABC Sequence | +------------+------------+------------+------------+--------------+ | iter()     |   \u043d\u0443\u0436\u0435\u043d    |   \u043d\u0443\u0436\u0435\u043d    |     +      |      +       | | contains() |     +      |     +      |     +      |      +       | | len()      |            |   \u043d\u0443\u0436\u0435\u043d    |   \u043d\u0443\u0436\u0435\u043d    |    \u043d\u0443\u0436\u0435\u043d     | | getitem()  |            |            |   \u043d\u0443\u0436\u0435\u043d    |    \u043d\u0443\u0436\u0435\u043d     | | reversed() |            |            |     +      |      +       | | index()    |            |            |            |      +       | | count()    |            |            |            |      +       | +------------+------------+------------+------------+--------------+<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u0432\u043e\u043e\u0431\u0449\u0435, \u043f\u043e\u0442\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u043f\u0440\u0438\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435\u0441\u044c \u0441 collections.abc, \u0442\u0430\u043c \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0432\u0430\u043c \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043d\u0435\u043c\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043a \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u043c \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e ABC Sequence __getitem__ \u0438 __len__ \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c __setitem__, __delitem__ \u0438 insert, \u0442\u043e \u0432 \u043e\u0442\u0432\u0435\u0442 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e MutableSequence, \u043a\u043e\u0442\u043e\u0440\u0430\u044f, \u043a\u0440\u043e\u043c\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 Sequence, \u0438\u043c\u0435\u0435\u0442 \u0435\u0449\u0435 \u043c\u0435\u0442\u043e\u0434\u044b append, reverse, extend, pop, remove \u0438 __iadd__.<\/p>\n<p>  <\/p>\n<h3 id=\"kopirovanie-obektov\">\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432<\/h3>\n<p>  <\/p>\n<p>\u0412 Python \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u044f (=) \u043d\u0435 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u0438 \u0438\u043c\u0435\u043d\u0435\u043c \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043f\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 Python, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c copy. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043e\u043f\u0438\u0439 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0434\u0443\u043b\u044f copy.<\/p>\n<p>  <\/p>\n<p>Shallow Copy \u2013 \u044d\u0442\u043e \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u0430\u044f \u043a\u043e\u043f\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u0421\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u043c\u0435\u0435\u0442 \u0442\u043e\u0447\u043d\u0443\u044e \u043a\u043e\u043f\u0438\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0435. \u0415\u0441\u043b\u0438 \u043e\u0434\u043d\u043e \u0438\u0437 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u043e\u043f\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0434\u0440\u0435\u0441\u0430 \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u043d\u0438\u0445.<\/p>\n<p>  <\/p>\n<p>Deep Copy \u2013 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a \u0446\u0435\u043b\u0435\u0432\u043e\u043c\u0443, \u0442. \u0435. \u0434\u0443\u0431\u043b\u0438\u0440\u0443\u0435\u0442 \u0434\u0430\u0436\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from copy import copy, deepcopy  class A:     def __init__(self, val: list):         self.val = val      def change_val(self, val: list):         self.val = val  a = A(list(\"one\"))  # \u041f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 b = a  # Assignment  # \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u0432 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0435 c = copy(a)  # Shallow copy  # \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u043c \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0445\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 d = deepcopy(a)  # Deep Copy  b.change_val(list(\"two\")) c.change_val(list(\"three\")) d.change_val(list(\"four\"))  print(a.val, b.val, c.val, d.val) print(id(a), id(b), id(c), id(d)) print(id(a.val[1]), id(c.val[1]))<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">['t', 'w', 'o'] ['t', 'w', 'o'] ['t', 'h', 'r', 'e', 'e'] ['f', 'o', 'u', 'r'] 1795295519472 1795295519472 1793149281968 1793149273808 1795217224688 1795217321264<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"nasledovanie\">\u041d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">class Person:     def __init__(self, name, age):         self.name = name         self.age = age  class Employee(Person):     def __init__(self, name, age, staff_num, email):         super().__init__(name, age)         self.staff_num = staff_num         self.email = email<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"mnozhestvennoe-nasledovanie\">\u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 (method resolution order, MRO) \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u041f\u0438\u0442\u043e\u043d\u0443 \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c, \u0438\u0437 \u043a\u0430\u043a\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430-\u043f\u0440\u0435\u0434\u043a\u0430 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434, \u0435\u0441\u043b\u0438 \u043e\u043d \u043d\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u043a\u043b\u0430\u0441\u0441\u0435-\u043f\u043e\u0442\u043e\u043c\u043a\u0435.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class PrivateStaffData:     def __init__(self, private_email):         self.private_email = private_email  class PublicStaffData:     def __init__(self, work_email):         self.work_email = work_email  class StaffData(PrivateStaffData, PublicStaffData):     def __init__(self, private_email, work_email):         super().__init__()  print(StaffData.mro())<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">[&lt;class '__main__.StaffData'>, &lt;class '__main__.PrivateStaffData'>, &lt;class '__main__.PublicStaffData'>, &lt;class 'object'>]<\/code><\/pre>\n<p>  <\/p>\n<p>MRO \u0441\u0442\u0440\u043e\u0438\u0442 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0431\u043e\u043b\u0435\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430-\u043f\u043e\u0442\u043e\u043c\u043a\u0430 \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0432\u0430\u043b\u0438 \u043c\u0435\u043d\u0435\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430-\u043f\u0440\u0435\u0434\u043a\u0430. MRO \u0441\u0442\u0440\u043e\u0438\u0442 \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u0438\u0441\u043a \u043c\u0435\u0442\u043e\u0434\u0430 \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e (\u043b\u0438\u043d\u0435\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430). <\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0440\u043e\u043c\u0431\u043e\u0432\u0438\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b (\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435\u044f\u0432\u043d\u043e \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0430\u0436\u0435 \u0432 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u0441\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u043e\u0442 object) \u043b\u0438\u043d\u0435\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043c\u043e\u043d\u043e\u0442\u043e\u043d\u043d\u043e\u0439. \u041c\u043e\u043d\u043e\u0442\u043e\u043d\u043d\u043e\u0441\u0442\u044c \u2014 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u0432 \u043b\u0438\u043d\u0435\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430-\u043f\u043e\u0442\u043e\u043c\u043a\u0430 \u0442\u043e\u0433\u043e \u0436\u0435 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432-\u043f\u0440\u0430\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u0439, \u0447\u0442\u043e \u0438 \u0432 \u043b\u0438\u043d\u0435\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430-\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f. \u041b\u0438\u043d\u0435\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e \u0441\u0443\u0442\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"https:\/\/en.wikipedia.org\/wiki\/Topological_sorting\" rel=\"nofollow noopener noreferrer\">\u0442\u043e\u043f\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u043e\u0439<\/a>. \u0412 \u0440\u0430\u043d\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 Python \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c DLR, \u0441\u0435\u0439\u0447\u0430\u0441 \u0432 \u0445\u043e\u0434\u0443 <a href=\"https:\/\/en.wikipedia.org\/wiki\/C3_linearization\" rel=\"nofollow noopener noreferrer\">C3-\u043b\u0438\u043d\u0435\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u044f<\/a>. <\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043c\u043e\u043d\u043e\u0442\u043e\u043d\u043d\u043e\u0441\u0442\u0438 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043b\u0438\u043d\u0435\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u0442\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0440\u0448\u0438\u043d\u0441\u0442\u0432\u0430 (local precedence ordering), \u0442. \u0435. \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432-\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u0439 \u0432 \u043b\u0438\u043d\u0435\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430-\u043f\u043e\u0442\u043e\u043c\u043a\u0430 \u0442\u043e\u0433\u043e \u0436\u0435 \u043f\u043e\u0440\u044f\u0434\u043a\u0430, \u0447\u0442\u043e \u0438 \u043f\u0440\u0438 \u0435\u0433\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043a\u043b\u0430\u0441\u0441 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u043a\u0430\u043a D(A, B, C), \u0442\u043e \u0432 \u043b\u0438\u043d\u0435\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u0438 D \u043a\u043b\u0430\u0441\u0441 A \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u0442\u043e\u044f\u0442\u044c \u0440\u0430\u043d\u044c\u0448\u0435 B, \u0430 \u043a\u043b\u0430\u0441\u0441 B \u2014 \u0440\u0430\u043d\u044c\u0448\u0435 C. <\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043e\u0432 \u043f\u0440\u0438 \u043b\u0438\u043d\u0435\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0442\u043e \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u0440\u0438 \u043f\u0443\u0442\u0438:<br \/>  1 \u2014 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043e\u0439 \u043c\u0435\u0441\u0442 \u043a\u043b\u0430\u0441\u0441\u043e\u0432-\u043f\u0440\u0435\u0434\u043a\u043e\u0432 \u0432 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430-\u043f\u043e\u0442\u043e\u043c\u043a\u0430 (\u043d\u043e \u044d\u0442\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430);<br \/>  2 \u2014 \u043f\u0435\u0440\u0435\u0441\u043c\u043e\u0442\u0440 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f;<br \/>  3 \u2014 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0435\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043b\u0438\u043d\u0435\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u044b \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 mro(cls). \u041d\u043e \u043f\u0440\u0438 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043d\u0430\u0434\u043e \u0431\u044b\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u043c \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u043c\u0435\u043d\u0435\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430-\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f \u0432\u043c\u0435\u0441\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043a\u043b\u0430\u0441\u0441\u0430-\u043f\u043e\u0442\u043e\u043c\u043a\u0430. <\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u0438 \u0441\u0432\u043e\u0435\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043b\u0438\u043d\u0435\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u0438 Python \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438. <\/p>\n<p>  <\/p>\n<h3 id=\"nasledovanie-klassov-so-__slots__\">\u041d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441\u043e __slots__<\/h3>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u043e\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 __slots__ \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 __dict__:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class SlotsClass:   __slots__ = 'foo', 'bar'  class ChildSlotsClass(SlotsClass):   ...  obj = ChildSlotsClass() print(obj.__slots__)  obj.something_new = \"underwater stones\" print(obj.__dict__)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">('foo', 'bar') {'something_new': 'underwater stones'}<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u043b\u043e\u0442\u0430\u043c\u0438 \u043d\u0443\u0436\u043d\u043e \u0432 \u043d\u0451\u043c \u0441\u043d\u043e\u0432\u0430 \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0443 __slots__, \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043f\u043e\u043b\u044f \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class SlotsClass:   __slots__ = 'foo', 'bar'  class ChildSlotsClass(SlotsClass):   __slots__ = 'baz'  obj = ChildSlotsClass() # obj.something_new = \"underwater stones\"  # Raises AttributeError: 'ChildSlotsClass' object has no attribute 'something_new'<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0436\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441 <em>\u043d\u0435\u043f\u0443\u0441\u0442\u044b\u043c\u0438<\/em> __slots__ \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e.<\/p>\n<p>  <\/p>\n<h3 id=\"metaprogrammirovanie\">\u041c\u0435\u0442\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043a\u043b\u0430\u0441\u0441? \u042d\u0442\u043e, \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0443\u0441\u043e\u043a \u043a\u043e\u0434\u0430, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442. \u041d\u043e \u0432 Python \u043a\u043b\u0430\u0441\u0441 \u2014 \u044d\u0442\u043e \u043d\u0435\u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0435, \u043a\u043b\u0430\u0441\u0441\u044b \u0442\u0430\u043a\u0436\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438; \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e class, Python \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043e\u0431\u044a\u0435\u043a\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class A:     ...<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043f\u0430\u043c\u044f\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c A.<\/p>\n<p>  <\/p>\n<p>\u041a\u043b\u0430\u0441\u0441\u044b, \u043a\u0430\u043a \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0430 \u0445\u043e\u0434\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">def custom_class(name):     if name == \"foo\":         class Foo:             ...          return Foo  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u043a\u043b\u0430\u0441\u0441, \u0430 \u043d\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440     else:         class Bar:             ...          return Bar  MyClass = custom_class(\"foo\") print(MyClass)  # \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441, \u0430 \u043d\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 print(my_class := MyClass())  # \u041c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">&lt;class '__main__.custom_class.&lt;locals>.Foo'> &lt;__main__.custom_class.&lt;locals>.Foo object at 0x000001F0ECF97610><\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>  <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0446\u0435\u043b\u044c \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u2014 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044f \u043a\u043b\u0430\u0441\u0441\u044b \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c.<br \/>  \u0421\u0430\u043c\u0438 \u043f\u043e \u0441\u0435\u0431\u0435 \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u044b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<br \/>  \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430,<br \/>  \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442 \u043a\u043b\u0430\u0441\u0441,<br \/>  \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441.<\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043d\u0430\u0441\u044b\u0449\u0430\u044e\u0442 \u0432\u0435\u0449\u0430\u043c\u0438 \u0432\u0440\u043e\u0434\u0435 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Type_introspection#Python\" rel=\"nofollow noopener noreferrer\">\u0438\u043d\u0442\u0440\u043e\u0441\u043f\u0435\u043a\u0446\u0438\u0438<\/a> \u0438\u043b\u0438 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0435\u0439 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u043e.<\/p>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0435 \u043f\u0430\u0440\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043f\u0440\u043e \u043d\u044c\u044e\u0430\u043d\u0441\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044c\u0442\u0435 \u043f\u0435\u0440\u0435\u0430\u0434\u0440\u0435\u0441\u043e\u0432\u0430\u0442\u044c \u0432\u0430\u0441 \u043d\u0430 \u0432\u043e\u0442 \u044d\u0442\u0443 <a href=\"https:\/\/habr.com\/ru\/post\/145835\/\">\u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e<\/a>.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0435\u0448\u0430\u044e\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u0447\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0434\u043b\u044f ORM. \u0421\u043a\u0430\u0436\u0435\u043c, \u0434\u043b\u044f<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class Person(models.Model):     name = models.CharField(max_length=30)     age = models.IntegerField()<\/code><\/pre>\n<p>  <\/p>\n<p>\u043a\u043e\u0434<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">keanu = Person(name=\"Keanu Reeves\", age=58)     print(keanu.age)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0440\u0430\u0441\u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0447\u0438\u0441\u043b\u043e, \u0432\u0437\u044f\u0442\u043e\u0435 \u0438\u0437 \u0411\u0414, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e models.Model \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 __metaclass__, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0442\u0432\u043e\u0440\u0438\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u0430\u0433\u0438\u044e \u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442 \u043a\u043b\u0430\u0441\u0441 Person, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c, \u0432 \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0443 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u0441\u0451 \u0435\u0449\u0435 \u043b\u043e\u043c\u0430\u0435\u0442\u0435 \u0433\u043e\u043b\u043e\u0432\u0443, \u0433\u0434\u0435 \u0431\u044b \u0432\u0430\u043c \u043f\u0440\u0438\u0448\u0438\u0442\u044c \u043c\u0435\u0442\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0441\u0432\u043e\u0451\u043c \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u043e\u043c \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c \u0432 \u0440\u0435\u0437\u044e\u043c\u0435, \u0442\u043e \u0432\u043e\u0442 \u0432\u0430\u043c \u043d\u0430 147 % \u0443\u043c\u0435\u0441\u0442\u043d\u0430\u044f \u0446\u0438\u0442\u0430\u0442\u0430 \u0438\u0437 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Tim_Peters_(software_engineer)\" rel=\"nofollow noopener noreferrer\">\u0422\u0438\u043c\u0430 \u041f\u0438\u0442\u0435\u0440\u0441\u0430<\/a>: \u00ab[Metaclasses] are deeper magic than 99% of users should ever worry about. If you wonder whether you need them, you don\u2019t (the people who actually need them know with certainty that they need them, and don\u2019t need an explanation about why)\u00bb, \u0447\u0442\u043e \u0432 \u0432\u043e\u043b\u044c\u043d\u043e\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u00ab\u041c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0443\u0436\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u043c \u0432 \u0441\u0435\u0431\u0435 \u043b\u044e\u0434\u044f\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u044e\u0442, \u0447\u0435\u0433\u043e \u0445\u043e\u0442\u044f\u0442 \u043e\u0442 \u0436\u0438\u0437\u043d\u0438, \u0430 \u0432\u043e\u0432\u0441\u0435 \u043d\u0435 \u0442\u0435\u0431\u0435\u00bb.<\/p>\n<p>  <\/p>\n<h3 id=\"abstractmethod\">@abstractmethod<\/h3>\n<p>  <\/p>\n<p>\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0432 Python \u2014 \u0430\u043d\u0430\u043b\u043e\u0433 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 C#) \u2014 \u043a\u043b\u0430\u0441\u0441, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0431\u0435\u0437 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u0435\u0440\u0435\u043b\u043e\u0436\u0435\u043d\u0430 \u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u044b-\u043f\u043e\u0442\u043e\u043c\u043a\u0438. \u0417\u0430\u0434\u0430\u0447\u0430 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u2014 <em>\u043e\u0431\u044f\u0437\u0430\u0442\u044c<\/em> \u043a\u043b\u0430\u0441\u0441\u044b-\u043f\u043e\u0442\u043e\u043c\u043a\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c <em>\u0432\u0441\u0435<\/em> \u043c\u0435\u0442\u043e\u0434\u044b, \u0437\u0430\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435-\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import abc  class AbstractClass(metaclass=abc.ABCMeta):      @abc.abstractmethod     def return_anything(self):         return  class ConcreteClass(AbstractClass):      def return_anything(self):         return 42  c = ConcreteClass() print(c.return_anything())<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">42<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c return_anything() \u0432 ConcreteClass, \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0432\u044b\u0437\u0432\u0430\u0442\u044c c.return_anything() \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 TypeError: Can&#8217;t instantiate abstract class ConcreteClass with abstract method return_anything.<\/p>\n<p>  <\/p>\n<h2 id=\"istochniki\">\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438<\/h2>\n<p>  <\/p>\n<p>\u041e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f Python <a href=\"https:\/\/docs.python.org\/\" rel=\"nofollow noopener noreferrer\">docs.python.org<\/a>, \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0430\u044f <a href=\"https:\/\/docs.python.org\/3\/library\/index.html\" rel=\"nofollow noopener noreferrer\">The Python Standard Library<\/a>.<br \/>  \u0412\u0435\u0441\u044c\u043c\u0430 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e (\u0441\u043e\u0432\u0441\u0435\u043c \u0443\u0436 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d): <a href=\"https:\/\/github.com\/gto76\/python-cheatsheet\" rel=\"nofollow noopener noreferrer\">Comprehensive Python Cheatsheet<\/a>.<br \/>  \u0420\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u0441 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430: <a href=\"https:\/\/github.com\/wilfredinni\/python-cheatsheet\" rel=\"nofollow noopener noreferrer\">Python Cheatsheet<\/a>. \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 Jupiter <a href=\"https:\/\/github.com\/wilfredinni\/python-cheatsheet\/tree\/master\/jupyter_notebooks\" rel=\"nofollow noopener noreferrer\">Notebooks<\/a>.<br \/>  \u0421\u0438\u043f\u0441\u043e\u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432: <a href=\"https:\/\/github.com\/vinta\/awesome-python\" rel=\"nofollow noopener noreferrer\">Awesome Python<\/a>.<br \/>  \u041e\u043a\u043e\u043b\u043e-\u043f\u0438\u0442\u043e\u043d\u043e\u0432\u0441\u043a\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u043e\u0432\u0435\u0442\u044b (pip, virtualenv, pyInstaller \u0438 \u0442. \u0434.): <a href=\"https:\/\/github.com\/realpython\/python-guide\" rel=\"nofollow noopener noreferrer\">&#171;The Hitchhiker\u2019s Guide to Python&#187;<\/a>.<br \/>  \u041c\u0430\u043d\u0443\u0430\u043b \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445 \u0434\u0430\u0442\u0430-\u0441\u0430\u0439\u0435\u043d\u0442\u0438\u0441\u0442\u043e\u0432: <a href=\"https:\/\/github.com\/joelgrus\/data-science-from-scratch\" rel=\"nofollow noopener noreferrer\">Joel Grus, &#171;Data Science from Scratch&#187;<\/a>.<br \/>  \u0420\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445: <a href=\"https:\/\/goalkicker.com\/PythonBook\/\" rel=\"nofollow noopener noreferrer\">&#171;Python Notes for Professionals&#187;<\/a>.<br \/>  \u0420\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u043e\u043f\u044b\u0442\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432: <a href=\"https:\/\/python-3-patterns-idioms-test.readthedocs.io\/en\/latest\/index.html\" rel=\"nofollow noopener noreferrer\">&#171;Python 3 Patterns, Recipes and Idioms&#187;<\/a>.<br \/>  \u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b: <a href=\"https:\/\/www.cosmicpython.com\/book\/preface.html\" rel=\"nofollow noopener noreferrer\">Harry Percival &amp; Bob Gregory, &#171;Architecture Patterns with Python&#187;<\/a>.<\/p>\n<\/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\/728568\/\"> https:\/\/habr.com\/ru\/articles\/728568\/<\/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\">\n<p>\u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u041c\u0438\u0445\u0430\u0438\u043b \u0415\u043c\u0435\u043b\u044c\u044f\u043d\u043e\u0432, \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b \u043d\u0430 \u00ab\u0425\u0430\u0431\u0440\u0435\u00bb \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e <a href=\"https:\/\/habr.com\/ru\/articles\/697760\/\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u043c \u043f\u0443\u0442\u0435\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u043c \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0435\u0433\u043e Python-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430. \u041f\u043e\u043b\u044c\u0437\u0443\u044f\u0441\u044c \u044d\u0442\u0438\u043c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u043c \u043a\u0430\u043a \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 \u043e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043a\u043d\u0438\u0433\u0438, \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043f\u0435\u0440\u0432\u044b\u0435 \u0447\u0435\u0442\u044b\u0440\u0435 \u0433\u043b\u0430\u0432\u044b \u043c\u0438\u043d\u0438-\u0443\u0447\u0435\u0431\u043d\u0438\u043a\u0430 \u00ab\u042f\u0434\u0440\u043e \u043f\u043b\u0430\u043d\u0435\u0442\u044b Python\u00bb, \u0433\u0434\u0435 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043a\u043e\u0440\u043e\u0442\u043a\u043e, \u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0451\u043c\u043a\u043e \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0443, \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e, \u043a\u0440\u0430\u0441\u043e\u0442\u0443 \u0438 \u0441\u0438\u043b\u0443 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430.<\/p>\n<p>  <\/p>\n<p>\u041e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0443\u0447\u0435\u0431\u043d\u0438\u043a\u0430 \u043b\u0435\u0436\u0438\u0442 \u043d\u0430 <a href=\"https:\/\/github.com\/amaargiru\/pycore\" rel=\"nofollow noopener noreferrer\">GitHub<\/a>, \u0432\u044b \u0432\u043e\u043b\u044c\u043d\u044b \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0433\u043e\u0434\u043d\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e. \u0421\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u0443\u0447\u0435\u0431\u043d\u0438\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 Jupiter Notebook, \u0430 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434, \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u043d\u043e\u0432\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0438\u043b\u0438 \u043f\u0440\u043e\u044f\u0441\u043d\u044f\u044f \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/post_images\/58f\/2c5\/a2c\/58f2c5a2c6142c8bee312e39ec2f4f00.jpg\" alt=\"Core of the planet Python\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/58f\/2c5\/a2c\/58f2c5a2c6142c8bee312e39ec2f4f00.jpg\" data-blurred=\"true\"\/><\/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-394677","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/394677","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=394677"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/394677\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=394677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=394677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=394677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}