{"id":232757,"date":"2014-08-09T00:17:03","date_gmt":"2014-08-08T20:17:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=232757"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=232757","title":{"rendered":"<span class=\"post_title\">\u0412\u044b\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 python \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0437\u0430\u0434\u0430\u0447 \u0438\u0437 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u0438\u043a\u0438<\/span>"},"content":{"rendered":"<div class=\"content html_format\">     \t<habracut\/>\u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0441\u0430\u043c\u043e\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u044f\u0437\u044b\u043a\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f python(\u0438\u043c\u0435\u044f \u0437\u043d\u0430\u043d\u0438\u044f \u0441\/\u0441++) \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9A%D0%BE%D0%BC%D0%B1%D0%B8%D0%BD%D0%B0%D1%82%D0%BE%D1%80%D0%B8%D0%BA%D0%B0\">\u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u043d\u044b\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439<\/a>. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0441\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 python \u0432 \u043c\u043e\u0434\u0443\u043b\u0435 itertools, \u043d\u043e \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043f\u0440\u0430\u0432\u043e \u0438\u0437\u043e\u0431\u0440\u0435\u0441\u0442\u0438 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434, \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0432 \u0446\u0435\u043b\u044f\u0445 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f\u2026<br \/>   \u0422\u043e\u0442 \u043a\u0442\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u0441 \u043e\u0441\u043d\u043e\u0432\u0430\u043c\u0438 \u0442\u0435\u043e\u0440\u0438\u0438 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0435\u0439 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0443\u0440\u043d\u043e\u0432\u044b\u0435 \u0441\u0445\u0435\u043c\u044b \u0438 \u043e \u0447\u0435\u043c \u044d\u0442\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/files\/f2e\/b23\/a2f\/f2eb23a2f8484c1395b98ec1af9e370a.png\"\/><\/p>\n<p>  \u0418 \u0442\u0430\u043a \u0422\u0417 \u2014 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0435\u0442\u044b\u0440\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0443 <b>s<\/b>, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0443\u044e \u0438\u0437 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 <b>\u043a<\/b>, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u2014 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0441 \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0435\u043c\/\u0431\u0435\u0437 \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0439 \u0438\u0437 <b>k <\/b> \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0441\u0442\u0440\u043e\u043a\u0438 <b>s<\/b> \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432\u0430\u0436\u0435\u043d\/\u043d\u0435 \u0432\u0430\u0436\u0435\u043d.<br \/>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">import math  def template(s, k, assertion = None, reducer = None):     n = len(s)     assert assertion(n, k)          if k == 0:         yield &quot;&quot;         return     elif k == 1:         for c in s:             yield c         return      k-=1     for i in range(n):         c = s[i]         new_s = reducer(s,i)         if not assertion(len(new_s), k):             break         for res in template(new_s, k, assertion, reducer):             yield c+res              assertion_norep = lambda n, k: n &gt; 0 and n &gt;= k and k &gt;= 0 assertion_rep   = lambda n, k: n &gt; 0 and k &gt;= 0  def permutation_norep(s, k):     return template(s, k, assertion = assertion_norep, reducer = lambda s, i: s[:i]+s[i+1:])      def permutation_rep(s, k):     return template(s, k, assertion = assertion_rep, reducer = lambda s, i: s)  def combination_norep(s, k):     return template(s, k, assertion = assertion_norep, reducer = lambda s, i: s[i+1:])      def combination_rep(s, k):     return template(s, k, assertion = assertion_rep, reducer = lambda s, i: s[i:])  test = &quot;abcdefg&quot; k = 5 n = len(test)      assert len(set(permutation_norep(test, k)))  == (math.factorial(n) \/ math.factorial(n-k)) assert len(list(permutation_norep(test, k))) == (math.factorial(n) \/ math.factorial(n-k))  assert len(set(permutation_rep(test, k)))    == n**k assert len(list(permutation_rep(test, k)))   == n**k  assert len(set(combination_norep(test, k)))  == (math.factorial(n) \/ (math.factorial(n-k)*math.factorial(k))) assert len(list(combination_norep(test, k))) == (math.factorial(n) \/ (math.factorial(n-k)*math.factorial(k)))  assert len(set(combination_rep(test, k)))    == (math.factorial(n+k-1) \/ (math.factorial(n-1)*math.factorial(k))) assert len(list(combination_rep(test, k)))   == (math.factorial(n+k-1) \/ (math.factorial(n-1)*math.factorial(k)))      <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a python \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u044f\u0437\u044b\u043a\u043e\u043c \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438, \u0447\u0435\u043c \u0441\/\u0441++, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0449\u0435 \u0438 \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b \u0431\u044b \u0431\u043e\u043b\u0435\u0435 \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u043e \u0438 \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u0435\u0435. \u041d\u043e\u0432\u0438\u0447\u043a\u0430\u043c \u0432 python \u044f \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<ul>\n<li>return \u043f\u043e\u0441\u043b\u0435 yield<\/li>\n<li>\u0420\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440<\/li>\n<li>\u0428\u0430\u0431\u043b\u043e\u043d \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f<\/li>\n<li>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 lambda \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/li>\n<\/ul>\n<p>  P.S.<br \/>  \u041c\u043e\u0433\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u044f \u043d\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438\u0448\u0435\u043b \u043a \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u043c\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u044e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0435\u043c\u0443 \u043e\u0431\u0449\u0443\u044e \u00ab\u0448\u0430\u0431\u043b\u043e\u043d\u043d\u0443\u044e\u00bb \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0430 \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u0434\u0435\u043b\u0438\u043b \u043e\u0431\u0449\u0435\u0435 \u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u043e\u0435.      \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/232757\/\"> http:\/\/habrahabr.ru\/post\/232757\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">     \t<habracut\/>\u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0441\u0430\u043c\u043e\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u044f\u0437\u044b\u043a\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f python(\u0438\u043c\u0435\u044f \u0437\u043d\u0430\u043d\u0438\u044f \u0441\/\u0441++) \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9A%D0%BE%D0%BC%D0%B1%D0%B8%D0%BD%D0%B0%D1%82%D0%BE%D1%80%D0%B8%D0%BA%D0%B0\">\u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u043d\u044b\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439<\/a>. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0441\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 python \u0432 \u043c\u043e\u0434\u0443\u043b\u0435 itertools, \u043d\u043e \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043f\u0440\u0430\u0432\u043e \u0438\u0437\u043e\u0431\u0440\u0435\u0441\u0442\u0438 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434, \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0432 \u0446\u0435\u043b\u044f\u0445 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f\u2026<br \/>   \u0422\u043e\u0442 \u043a\u0442\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u0441 \u043e\u0441\u043d\u043e\u0432\u0430\u043c\u0438 \u0442\u0435\u043e\u0440\u0438\u0438 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0435\u0439 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0443\u0440\u043d\u043e\u0432\u044b\u0435 \u0441\u0445\u0435\u043c\u044b \u0438 \u043e \u0447\u0435\u043c \u044d\u0442\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430:<\/p>\n<p>  \u0418 \u0442\u0430\u043a \u0422\u0417 \u2014 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0435\u0442\u044b\u0440\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0443 <b>s<\/b>, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0443\u044e \u0438\u0437 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 <b>\u043a<\/b>, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u2014 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0441 \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0435\u043c\/\u0431\u0435\u0437 \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0439 \u0438\u0437 <b>k <\/b> \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0441\u0442\u0440\u043e\u043a\u0438 <b>s<\/b> \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432\u0430\u0436\u0435\u043d\/\u043d\u0435 \u0432\u0430\u0436\u0435\u043d.<br \/>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">import math  def template(s, k, assertion = None, reducer = None):     n = len(s)     assert assertion(n, k)          if k == 0:         yield &quot;&quot;         return     elif k == 1:         for c in s:             yield c         return      k-=1     for i in range(n):         c = s[i]         new_s = reducer(s,i)         if not assertion(len(new_s), k):             break         for res in template(new_s, k, assertion, reducer):             yield c+res              assertion_norep = lambda n, k: n &gt; 0 and n &gt;= k and k &gt;= 0 assertion_rep   = lambda n, k: n &gt; 0 and k &gt;= 0  def permutation_norep(s, k):     return template(s, k, assertion = assertion_norep, reducer = lambda s, i: s[:i]+s[i+1:])      def permutation_rep(s, k):     return template(s, k, assertion = assertion_rep, reducer = lambda s, i: s)  def combination_norep(s, k):     return template(s, k, assertion = assertion_norep, reducer = lambda s, i: s[i+1:])      def combination_rep(s, k):     return template(s, k, assertion = assertion_rep, reducer = lambda s, i: s[i:])  test = &quot;abcdefg&quot; k = 5 n = len(test)      assert len(set(permutation_norep(test, k)))  == (math.factorial(n) \/ math.factorial(n-k)) assert len(list(permutation_norep(test, k))) == (math.factorial(n) \/ math.factorial(n-k))  assert len(set(permutation_rep(test, k)))    == n**k assert len(list(permutation_rep(test, k)))   == n**k  assert len(set(combination_norep(test, k)))  == (math.factorial(n) \/ (math.factorial(n-k)*math.factorial(k))) assert len(list(combination_norep(test, k))) == (math.factorial(n) \/ (math.factorial(n-k)*math.factorial(k)))  assert len(set(combination_rep(test, k)))    == (math.factorial(n+k-1) \/ (math.factorial(n-1)*math.factorial(k))) assert len(list(combination_rep(test, k)))   == (math.factorial(n+k-1) \/ (math.factorial(n-1)*math.factorial(k)))      <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a python \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u044f\u0437\u044b\u043a\u043e\u043c \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438, \u0447\u0435\u043c \u0441\/\u0441++, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0449\u0435 \u0438 \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b \u0431\u044b \u0431\u043e\u043b\u0435\u0435 \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u043e \u0438 \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u0435\u0435. \u041d\u043e\u0432\u0438\u0447\u043a\u0430\u043c \u0432 python \u044f \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<ul>\n<li>return \u043f\u043e\u0441\u043b\u0435 yield<\/li>\n<li>\u0420\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440<\/li>\n<li>\u0428\u0430\u0431\u043b\u043e\u043d \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f<\/li>\n<li>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 lambda \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/li>\n<\/ul>\n<p>  P.S.<br \/>  \u041c\u043e\u0433\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u044f \u043d\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438\u0448\u0435\u043b \u043a \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u043c\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u044e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0435\u043c\u0443 \u043e\u0431\u0449\u0443\u044e \u00ab\u0448\u0430\u0431\u043b\u043e\u043d\u043d\u0443\u044e\u00bb \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0430 \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u0434\u0435\u043b\u0438\u043b \u043e\u0431\u0449\u0435\u0435 \u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u043e\u0435.      \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/232757\/\"> http:\/\/habrahabr.ru\/post\/232757\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-232757","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/232757","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=232757"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/232757\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=232757"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=232757"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=232757"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}