{"id":288836,"date":"2018-09-01T15:45:02","date_gmt":"2018-09-01T11:45:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=288836"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=288836","title":{"rendered":"\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0441\u0442\u0438 \u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0441\u0442\u0438 python"},"content":{"rendered":"\n<div data-io-article-url=\"https:\/\/habr.com\/post\/421993\/\" class=\"post__text post__text-html js-mediator-article\">\u042f \u0443\u0436\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u0443\u044e \u043d\u0430 python, \u043e\u0434\u043d\u0430\u043a\u043e, \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u043e\u0441\u043e\u0437\u043d\u0430\u043b, \u0447\u0442\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u043f\u0440\u0438\u0451\u043c\u043e\u0432 \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u0440\u043e\u0448\u043b\u0438 \u043c\u0438\u043c\u043e \u043c\u0435\u043d\u044f, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044f \u043d\u0435 \u043e\u0434\u0438\u043d \u0442\u0430\u043a\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0448\u0438\u043b \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0438\u0445 \u0437\u0434\u0435\u0441\u044c, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u0451\u043c\u044b \u043f\u0440\u0438\u0433\u043e\u0434\u044f\u0442\u0441\u044f \u043a\u043e\u043c\u0443-\u0442\u043e \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0438\u043b\u0438 \u043f\u043e\u0431\u0443\u0434\u044f\u0442 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u044d\u0442\u0438\u043c \u044f\u0437\u044b\u043a\u043e\u043c \u043f\u043e\u0431\u043b\u0438\u0436\u0435.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041a\u0430\u043a \u0438 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u0432 python 1 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e True, \u0430 0 \u2014 False, \u0442\u043e \u0435\u0441\u0442\u044c<\/p>\n<pre><code class=\"python\"> 1 == True.<\/code><\/pre>\n<p>  \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0438 \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u043c \u0442\u0430\u043a\u043e\u0433\u043e? \u041e\u0434\u043d\u0430\u043a\u043e, \u044d\u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0445\u0435\u0448\u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443 \u0432\u0430\u0441 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0437\u0430\u043f\u0438\u0445\u0430\u0442\u044c \u0432 \u043e\u0434\u0438\u043d \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043a\u043b\u044e\u0447 1 \u0438 True.<\/p>\n<pre><code class=\"python\"> &gt;&gt;&gt; a = {1: &quot;one&quot;, 0: &quot;zero&quot;, True: &quot;true&quot;, False: &quot;false&quot;} # -&gt; {1: 'true', 0: 'false'} <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u0436\u0435 \u044d\u0442\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"python\"> &gt;&gt;&gt; print(2 * False + True) # -&gt; 1 <\/code><\/pre>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044f, \u043e\u0434\u043d\u0430\u043a\u043e, \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0435\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044f, \u043c\u0435\u043d\u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u0440\u0430\u0437\u0434\u0440\u0430\u0436\u0430\u043b\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043e\u043a, \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0432 \u043a\u0430\u0432\u044b\u0447\u043a\u0430\u0445, \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0438\u0445 \u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c, \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0435\u0441\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 dict().<\/p>\n<pre><code class=\"python\"> &gt;&gt;&gt; {&quot;one&quot;: 1, &quot;two&quot;: 2, &quot;three&quot;: 3} == dict(one=1, two=2, three=3) # -&gt; True <\/code><\/pre>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043e\u043a \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u0438, \u043d\u043e \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430(set).<\/p>\n<pre><code class=\"python\"> &gt;&gt;&gt; a = {1, 2, 3} <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432 \u043c\u043d\u0435 \u043f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c +, \u043d\u0430\u0432\u0435\u0440\u043d\u043e, \u0438\u0437-\u0437\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u043e\u043a. \u041e\u0434\u043d\u0430\u043a\u043e, python \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432. \u041d\u043e \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u044d\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043d\u0430\u043c \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438, \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0438 \u043f\u043e\u0434\u043e\u0448\u043b\u0438 \u043a \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0432\u043e\u043f\u0440\u043e\u0441\u0443 \u0431\u043e\u043b\u0435\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0432 \u044f\u0437\u044b\u043a \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043d\u0430\u0434 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u043c\u0438 (\u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f) \u0438 <a href=\"https:\/\/docs.python.org\/2\/library\/sets.html\">\u00ab\u043f\u043e\u0432\u0435\u0441\u0438\u043b\u0438\u00bb \u0438\u0445 \u043d\u0430 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b<\/a>.<\/p>\n<pre><code class=\"python\"> a = {1, 2, 3} b = {0, 2, 4} print(a & b)     # -&gt; {2} print(a | b)     # -&gt; {0, 1, 2, 3, 4} print(a ^ b)     # -&gt; {0, 1, 3, 4} print(a - b)     # -&gt; {1, 3}, \u043e\u0434\u043d\u0430\u043a\u043e \u043e\u0434\u0438\u043d \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439                  # \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0432\u0441\u0451 \u0436\u0435 \u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044f \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440 \u043f\u0440\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u0438, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 3.7 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439 \u044f\u0437\u044b\u043a\u0430 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, OrderedDict \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d.<\/p>\n<p>  <a href=\"https:\/\/www.python.org\/downloads\/release\/python-370\/\">www.python.org\/downloads\/release\/python-370<\/a><br \/>  <a href=\"https:\/\/mail.python.org\/pipermail\/python-dev\/2017-December\/151283.html\">mail.python.org\/pipermail\/python-dev\/2017-December\/151283.html<\/a><\/p>\n<pre><code class=\"python\"> d = dict(zero='Cero', one='Uno', two='Dos', three='Tres', four='Cuatro',          five='Cinco', six='Seis', seven='Siete', eight='Ocho', night='Nueve')  for index, (key, value) in enumerate(d.items()):     print(f&quot;{index} is {key} in England and {value} in Spain&quot;) <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0435 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432\u044b\u0432\u043e\u0434\u0430, \u043e\u043d\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u0430 f \u2014 \u044d\u0442\u043e \u043e\u0441\u043e\u0431\u044b\u0439 \u0442\u0438\u043f \u0441\u0442\u0440\u043e\u043a, \u0432\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u0432 <a href=\"https:\/\/www.python.org\/dev\/peps\/pep-0498\/\">python 3.6<\/a>.<\/p>\n<p>  \u0412\u0441\u0435\u0433\u043e \u0432 python \u0442\u0440\u0438 \u0432\u0438\u0434\u0430 \u0441\u0442\u0440\u043e\u043a: \u043e\u0431\u044b\u0447\u043d\u044b\u0435, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u043c\u044b\u0435 \u043a\u0430\u0432\u044b\u0447\u043a\u0430\u043c\u0438 \u0431\u0435\u0437 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u0432, \u0441\u044b\u0440\u044b\u0435\\\u043d\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0435(raw), \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043f\u0435\u0446-\u0441\u0438\u043c\u0432\u043e\u043b\u044b, \u0432\u0440\u043e\u0434\u0435, \\n \u043d\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u0442\u0435\u043a\u0441\u0442 \u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e f-\u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u043d\u044b \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0432\u044b\u0432\u043e\u0434\u0430, python \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0432\u044b\u0432\u043e\u0434\u0430:<\/p>\n<pre><code class=\"python\"> print(&quot;result&quot; + str(2))     # \u041f\u0440\u043e\u0441\u0442\u0430\u044f \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u044f \u0441\u0442\u0440\u043e\u043a, python \u043d\u0435 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442                              # \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043a                               # \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u043c\u0443 \u0442\u0438\u043f\u0443, \u044d\u0442\u043e \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0437\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u043c print(&quot;result&quot;, 2)           # print \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u043f\u044f\u0442\u0443\u044e,                              # \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0431\u0435\u043b,                              # \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u0441\u0442\u0440\u043e\u043a\u0443,                              # \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 print(&quot;result %d&quot; % 2)                 # %-\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441, \u0441\u0434\u0435\u043b\u0430\u043d \u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0441 \u044f\u0437\u044b\u043a\u043e\u043c C. print(&quot;result %d %.2f&quot; % (2, 2))       # https:\/\/docs.python.org\/3.4\/library\/string.html#formatspec print(&quot;result %(name)s&quot; % {&quot;name&quot;: 2}) # \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043a\u0438  print(&quot;{}&quot;.format(2))                  # \u0423 \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 format()                                        # \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u0438\u043f \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 print(&quot;{0} {1} {0}&quot;.format(1, 2)) # \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0438 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c         \t\t\t        # \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0435\u0451 \u0434\u0432\u0430 \u0440\u0430\u0437\u0430         \t\t\t        # \u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043d\u0443\u043b\u044f # \u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043c\u0435\u043d\u044c\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432 \u0432\u044b\u0432\u043e\u0434\u0435, \u0431\u0443\u0434\u0435\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 print(&quot;{} {}&quot;.format(2))            # -&gt; IndexError: tuple index out of range print(&quot;{0} {0}&quot;.format(2, 3))       # -&gt; 2 2 \u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445                                     # \u043a\u043e\u0434 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a from math import pi                 # \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u0432\u044b\u0432\u043e\u0434\u0435 \u0442\u0430\u043a \u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 print(&quot;{:.2f}&quot;.format(pi))          # -&gt; 3.14  from string import Template         # \u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d \u0438 \u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0432\u044b\u0432\u043e\u0434\u0430 s = Template(&quot;result  $res&quot;)        # \u043e\u0434\u043d\u0430\u043a\u043e \u043e\u043d \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0435\u0449\u0451 \u0438 f-\u0441\u0442\u0440\u043e\u043a\u0438. \u0412 \u043d\u0438\u0445 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043b\u044e\u0431\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438\u0437 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043f\u043e \u043a\u043b\u044e\u0447\u0443, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043e\u043d\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 \u0441\u0442\u0440\u043e\u043a\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0430.<\/p>\n<pre><code class=\"python\"> from math import pi result = 4 name = &quot;user&quot; print(f&quot;{name:84s} pi= {pi:.2f}, result={result}, {name[2]}&quot;) # -&gt; user                                                                                 pi= 3.14, result=4, e  from datetime import datetime print(f&quot;{datetime.now():%Y:%m-%d}&quot;) <\/code><\/pre>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u043e\u043d\u0438 <a href=\"https:\/\/shultais.education\/blog\/python-f-strings\">\u0431\u044b\u0441\u0442\u0440\u0435\u0435<\/a> \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0432\u044b\u0432\u043e\u0434\u0430, \u0442\u0430\u043a \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d python3.6 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0438\u0445.<\/p>\n<p>  \u041e\u0434\u043d\u0430 \u0438\u0437 \u043d\u0430\u0438\u043a\u0440\u0443\u0442\u0435\u0439\u0448\u0438\u0445 \u0444\u0438\u0448\u0435\u043a python \u2014 \u0432 \u043d\u0451\u043c \u0443\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u044b, \u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438.<\/p>\n<pre><code class=\"python\"> def func(*argv, **kwargs) <\/code><\/pre>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0439 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<ul>\n<li>argv \u2014 \u043a\u043e\u0440\u0442\u0435\u0436, \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c, \u043d\u0435\u043b\u044c\u0437\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/li>\n<li>kwargs \u2014 \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e<\/li>\n<\/ul>\n<p>  \u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0439, \u043d\u043e \u0432\u0441\u0451 \u0436\u0435 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c kwargs \u0432 \u043a\u0435\u0448, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u0441\u043b\u043e\u0432\u0430\u0440\u0435, \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0435\u0441\u043b\u0438 \u0432\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u0435 \u0432 \u043a\u043e\u0440\u0442\u0435\u0436 \u0441\u043f\u0438\u0441\u043e\u043a, \u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0440\u0442\u0435\u0436 \u0442\u043e\u0436\u0435 \u043d\u0435\u043b\u044c\u0437\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044c.<\/p>\n<p>  \u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0442\u043e\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0445\u0435\u0448\u0438\u0440\u0443\u0435\u043c\u044b, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u0441\u0430\u043c\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u043c \u0438 \u043d\u0435 \u0445\u0435\u0448\u0438\u0440\u0443\u0435\u043c\u044b\u043c \u0442\u0438\u043f\u043e\u043c, \u0435\u0441\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f frosenset \u2014 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e (\u043d\u0435 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0439\u0442\u0435 \u043c\u0435\u043d\u044f, \u0437\u0430\u0447\u0435\u043c \u043e\u043d\u043e \u043d\u0443\u0436\u043d\u043e).<\/p>\n<p>  \u041e\u0431\u0441\u0443\u0436\u0434\u0430\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 frosendict, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u043a\u0430 \u0435\u0433\u043e \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 (\u0445\u043e\u0442\u044f \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043e\u0434\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0435\u043c\u0443 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u2014 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 kwargs). \u0417\u0430 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0442\u0434\u0443\u0432\u0430\u0442\u044c\u0441\u044f <a href=\"https:\/\/docs.python.org\/3\/library\/collections.html#collections.namedtuple\">namedtuple<\/a>. \u0410 \u0442\u0430\u043a\u0436\u0435 \u0437\u0430 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b.<\/p>\n<p>  \u041a\u0442\u043e \u0432 \u0441\u0442\u0443\u0434\u0435\u043d\u0447\u0435\u0441\u043a\u0438\u0435\\\u0448\u043a\u043e\u043b\u044c\u043d\u044b\u0435 \u0433\u043e\u0434\u044b \u043f\u0438\u0441\u0430\u043b \u0446\u0438\u043a\u043b\u044b \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438 \u0431\u0435\u0441\u0438\u043b\u0441\u044f \u0438\u0437-\u0437\u0430 \u0437\u0430\u043f\u044f\u0442\u043e\u0439 \u0432 \u043a\u043e\u043d\u0446\u0435, \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0440\u0435\u0448\u0430\u043b, \u0437\u0430\u0431\u0438\u0442\u044c \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u043a\u0440\u0430\u0441\u0438\u0432\u043e, \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043a\u0443\u0440\u0441\u0435 2-3 \u0443\u0437\u043d\u0430\u043b \u043e \u043c\u0435\u0442\u043e\u0434\u0435 join? \u0418\u043b\u0438 \u044f \u043e\u0434\u0438\u043d \u0442\u0430\u043a\u043e\u0439?<\/p>\n<p>  \u041e\u0434\u043d\u0430 \u0438\u0437 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u043c\u0435\u0442\u043e\u0434\u0430 join \u0443 \u0441\u0442\u0440\u043e\u043a \u2014 \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438-\u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438, \u0435\u0441\u043b\u0438 \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0435\u0441\u0442\u044c \u0445\u043e\u0442\u044c \u043e\u0434\u043d\u0430 \u043d\u0435 \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u043e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441\u043f\u0438\u0441\u043a\u043e\u0432 (\u0431\u0435\u0437 \u0441\u043a\u043e\u0431\u043e\u043a).<\/p>\n<pre><code class=\"python\"> a = list(range(5)) print(&quot; &quot;.join(a))                 # -&gt; TypeError: sequence item 0: expected str instance, int found print(&quot; &quot;.join(str(i) for i in a)) # -&gt; 0 1 2 3 4 print(*a)                          # -&gt; 0 1 2 3 4 <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u0441\u0442\u0440\u043e\u043a\u0438 \u2014 \u0442\u043e\u0436\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438, \u0442\u043e \u0438\u0445 \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u00ab\u0434\u0436\u043e\u0439\u043d\u0438\u0442\u044c\u00bb.<\/p>\n<pre><code class=\"python\"> print('-'.join(&quot;hello&quot;))             # -&gt; h-e-l-l-o <\/code><\/pre>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430.<\/p>\n<pre><code class=\"python\"> print(&quot; &quot;.join(str(i) for i in a)) # -&gt; 0 1 2 3 4 <\/code><\/pre>\n<p>  \u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043e \u0432 \u0444-\u0446\u0438\u044e join \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043d\u0438\u0431\u0443\u0434\u044c \u0441\u043a\u043e\u0431\u043e\u043a, \u043a\u0440\u0443\u0433\u043b\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430. Python \u0437\u0430\u0431\u043e\u0442\u0438\u0442\u0441\u044f \u043e \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<pre><code class=\"python\"> print(sum(i**2 for i in range(10))) # -&gt; 285 <\/code><\/pre>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043a\u0440\u0443\u0433\u043b\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439:<\/p>\n<pre><code class=\"python\"> article = &quot;python&quot;, 2018, &quot;LinearLeopard&quot;            # \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0440\u0442\u0435\u0436\u0430 theme, year, author = &quot;python&quot;, 2018, &quot;LinearLeopard&quot;# \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0430 \u043a\u043e\u0440\u0442\u0435\u0436\u0430 theme, year, _ = &quot;python&quot;, 2018, &quot;LinearLeopard&quot;     # \u0441\u043b\u0435\u0432\u0430 \u0438 \u0441\u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u043b\u0436\u043d\u043e                                                      # \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0435 \u0447\u0438\u0441\u043b\u043e                                                      # \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u043d\u0443\u0442\u044c,                                                      # \u0447\u0442\u043e \u0432\u0430\u043c \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e,                                                      # \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u0432 \u0435\u0451 \u0447\u0435\u0440\u0435\u0437                                                      #  \u043f\u043e\u0434\u0447\u0451\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u0435 theme, _, _ = &quot;python&quot;, 2018, &quot;LinearLeopard&quot;        # \u0438\u043c\u0435\u043d\u0430 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c\u0441\u044f theme, * author = &quot;python&quot;, 2018, &quot;LinearLeopard&quot;    # \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0436\u0430\u0434\u043d\u044b\u0439                                                      # \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u044a\u0435\u0441\u0442                                                      # \u0432\u0441\u0435 \u043d\u0435\u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435,                                                      # \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c                                                      # \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d                                                      # \u0436\u0430\u0434\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <\/code><\/pre>\n<p>  \u0417\u0432\u0451\u0437\u0434\u043e\u0447\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0432 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c <a href=\"https:\/\/www.python.org\/dev\/peps\/pep-3102\/\">\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043a\u043b\u044e\u0447\u0443<\/a>.<\/p>\n<pre><code class=\"python\"> def sortwords(*wordlist, case_sensitive=False): <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u0444-\u0446\u0438\u044e \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0433\u043e\u0434\u043d\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0431\u0435\u0437 \u0431\u043e\u044f\u0437\u043d\u0438, \u0447\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u044f\u0442 \u043a\u0430\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 case_sensitive.<\/p>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0438 \u0442\u0430\u043a.<\/p>\n<pre><code class=\"python\"> def func(first, second, *, kwonly): <\/code><\/pre>\n<p>  \u0421 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u043e\u0434\u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c: \u043e\u043d\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f \u0432 \u0431\u0430\u0439\u0442 \u043a\u043e\u0434, \u0442\u0430\u043a \u0447\u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043c \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u0442\u0438\u043f\u044b. \u041e\u0431\u044a\u044f\u0432\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u043a\u043e\u043d\u0435\u0446 \u0441\u043f\u0438\u0441\u043a\u0430, \u0435\u0441\u043b\u0438 \u0432\u0442\u043e\u0440\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043e\u043f\u0443\u0449\u0435\u043d, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<pre><code class=\"python\"> def add_to(elem, collection=[]):     collection.append(elem)     return collection   a = [&quot;a&quot;, &quot;c&quot;] print(add_to(&quot;b&quot;, a))           # -&gt; ['a', 'c', 'b']  print(add_to(&quot;a&quot;))              # -&gt; ['a'] print(add_to(&quot;b&quot;))              # -&gt; ['a', 'b']  \u041e\u0442\u043a\u0443\u0434\u0430 \u0437\u0434\u0435\u0441\u044c 'a'? <\/code><\/pre>\n<p>  \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0444-\u0446\u0438\u044f \u0445\u0440\u0430\u043d\u0438\u0442 \u0432 \u043f\u043e\u043b\u0435 __defaults__, \u043c\u043e\u0436\u043d\u043e \u0432 \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0443\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f.<\/p>\n<pre><code class=\"python\"> print(add_to.__defaults__) # -&gt; (['a', 'b'],) <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e (\u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a) \u0441\u043e\u0437\u0434\u0430\u043b\u0441\u044f \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u0442\u0430\u0440\u0442\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438 \u043d\u0435 \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0437\u0430\u043d\u043e\u0432\u043e, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435.<\/p>\n<p>  \u0418\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e, \u0435\u0441\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u043c \u0442\u0438\u043f\u043e\u043c,<br \/>   \u0430 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u0442\u0435\u043b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"python\"> def add_to(elem, collection=None):     collection = collection or []     collection.append(elem)     return collection <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0443<\/p>\n<pre><code class=\"python\"> collection = collection or [] <\/code><\/pre>\n<p>  \u044d\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 (\u0438 \u043c\u0435\u043d\u0435\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439, \u0445\u043e\u0442\u044f \u043d\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445) \u0430\u043d\u0430\u043b\u043e\u0433<\/p>\n<pre><code class=\"python\"> collection = collection if collection else [] <\/code><\/pre>\n<\/div>\n<p>        <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <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\/post\/421993\/\"> https:\/\/habr.com\/post\/421993\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div data-io-article-url=\"https:\/\/habr.com\/post\/421993\/\" class=\"post__text post__text-html js-mediator-article\">\u042f \u0443\u0436\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u0443\u044e \u043d\u0430 python, \u043e\u0434\u043d\u0430\u043a\u043e, \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u043e\u0441\u043e\u0437\u043d\u0430\u043b, \u0447\u0442\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u043f\u0440\u0438\u0451\u043c\u043e\u0432 \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u0440\u043e\u0448\u043b\u0438 \u043c\u0438\u043c\u043e \u043c\u0435\u043d\u044f, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044f \u043d\u0435 \u043e\u0434\u0438\u043d \u0442\u0430\u043a\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0448\u0438\u043b \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0438\u0445 \u0437\u0434\u0435\u0441\u044c, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u0451\u043c\u044b \u043f\u0440\u0438\u0433\u043e\u0434\u044f\u0442\u0441\u044f \u043a\u043e\u043c\u0443-\u0442\u043e \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0438\u043b\u0438 \u043f\u043e\u0431\u0443\u0434\u044f\u0442 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u044d\u0442\u0438\u043c \u044f\u0437\u044b\u043a\u043e\u043c \u043f\u043e\u0431\u043b\u0438\u0436\u0435.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-288836","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/288836","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=288836"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/288836\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=288836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=288836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=288836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}