{"id":192098,"date":"2013-09-08T01:26:02","date_gmt":"2013-09-07T21:26:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=192098"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=192098","title":{"rendered":"<span class=\"post_title\">Python. \u041d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0442\u0430\u043a\u0438\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 + \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435, \u043d\u043e \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432 \u043a\u043e\u0434\u0435 \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c. \u0421\u0442\u0430\u0442\u044c\u044f \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u0430 \u043d\u0430 python \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 \u0441 \u043e\u043f\u044b\u0442\u043e\u043c 0 \u2014 1,5 \u0433\u043e\u0434\u0430. \u041e\u043f\u044b\u0442\u043d\u044b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432 \u043a\u043e\u043c\u0435\u043d\u0442\u0430\u0445 \u043f\u043e\u043a\u0440\u0438\u0442\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u0432\u043e\u0438\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438.<br \/>  <a name=\"habracut\"><\/a><br \/>  1. Lambda.<br \/>  \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f pw \u0432 lambda \u2014 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0430 \u043d\u0435 \u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u041a \u043c\u043e\u043c\u0435\u043d\u0442\u0443 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f pw \u0440\u0430\u0432\u043d\u0430 5  <\/p>\n<table>\n<tr>\n<td>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u0439 \u043a\u043e\u0434  <\/p>\n<pre><code class=\"python\">to_pow = {} for pw in xrange(5):      to_pow[pw] = lambda x: x ** pw  print to_pow[2](10)  # 10000 ???  <\/code><\/pre>\n<p>  <\/td>\n<td>\u0420\u0435\u0448\u0435\u043d\u0438\u0435: \u041f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 lambda \u044f\u0432\u043d\u043e  <\/p>\n<pre><code class=\"python\">to_pow = {}                        for pw in xrange(5):     to_pow[pw] = lambda x, pw=pw: x ** pw  print to_pow[2](10)  # 100  <\/code><\/pre>\n<p>  <\/td>\n<\/tr>\n<\/table>\n<p>  2. \u041e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u043e\u0438\u0441\u043a\u0430 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043f\u0440\u0438 \u0440\u043e\u043c\u0431\u043e\u0438\u0434\u0430\u043b\u044c\u043d\u043e\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u0432 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u0442\u0438\u043b\u044f  <\/p>\n<table>\n<tr>\n<td><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/f9d\/013\/f58\/f9d013f58b3861880ecf5c58f43cd766.jpg\"\/>  <\/td>\n<td>\n<pre><code class=\"python\">class A():     def field(self):         return 'a'    class B(A):      pass    class C(A):      def field(self):         return 'c'    class Entity(B, C):     pass   print Entity().field()  # a !!! <\/code><\/pre>\n<p>  <\/td>\n<td>\n<pre><code class=\"python\">class A():     def field(self):         return 'a'    class B(A):      pass    class C(A, object):  # New style class      def field(self):         return 'c'    class Entity(B, C):      pass   print Entity().field()  # c !!! <\/code><\/pre>\n<p>  <\/td>\n<\/tr>\n<\/table>\n<p>  3. \u0418\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e  <\/p>\n<table>\n<tr>\n<td>\u041c\u0430\u0433\u0438\u044f:  <\/p>\n<pre><code class=\"python\">def get_data(val=[]):      val.append(1)     return val  print get_data()  # [1] print get_data()  # [1, 1]    ??? print get_data()  # [1, 1, 1]    ??? <\/code><\/pre>\n<p>  <\/td>\n<td>\u0420\u0435\u0448\u0435\u043d\u0438\u0435:   <\/p>\n<pre><code class=\"python\">def get_data(val=None):      val = val or []     val.append(1)     return val   print get_data()  # [1]   print get_data()  # [1] <\/code><\/pre>\n<p>  <\/td>\n<\/tr>\n<\/table>\n<p>  4. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u043e\u0436\u0434\u044b  <\/p>\n<pre><code class=\"python\">import random def get_random_id(rand_id=random.randint(1, 100)):     return rand_id    print get_random_id()  # 53 print get_random_id()  # 53 ???  print get_random_id()  # 53 ???  <\/code><\/pre>\n<p>  5. \u041d\u0435 \u0443\u0447\u0442\u0435\u043d\u0430 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0434\u0435\u0440\u0436\u0438\u0442\u0435 \u0432 \u0433\u043e\u043b\u043e\u0432\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0441\u043f\u0438\u0441\u043a\u0438 <a href=\"http:\/\/docs.python.org\/2\/library\/exceptions.html#exception-hierarchy\">docs.python.org\/2\/library\/exceptions.html#exception-hierarchy<\/a> + \u0441\u043f\u0438\u0441\u043a\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 + \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 PyLint. \u0422\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  KeyError \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/p>\n<pre><code class=\"python\">try:     d = {}     d['xxx'] except LookupError:     print '1' except KeyError:     print '2'  <\/code><\/pre>\n<p>  6. \u041a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u043e\u043c \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0445 \u0441\u0442\u0440\u043e\u043a \u0438 \u0447\u0438\u0441\u0435\u043b <\/p>\n<pre><code class=\"python\">str1 = 'x' * 100 str2 = 'x' * 100 print str1 is str2  # False    str1 = 'x' * 10 str2 = 'x' * 10 print str1 is str2  # True ??? <\/code><\/pre>\n<p>  7. \u041d\u0435\u044f\u0432\u043d\u0430\u044f \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u044f.<br \/>  \u041f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u0430\u044f \u0437\u0430\u043f\u044f\u0442\u0430\u044f \u043d\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0430 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0441\u043b\u0438\u044f\u043d\u0438\u044e \u0441\u043c\u0435\u0436\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a. \u0422\u0430\u043a\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0442\u0438 \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u043a\u043e\u0440\u0442\u0435\u0436\u0435 \u043d\u0435 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0437\u0430\u043f\u044f\u0442\u0443\u044e, \u0430 \u0437\u0430\u0442\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u043a\u043e\u0440\u0442\u0435\u0436\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u043b\u0438, \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438  <\/p>\n<pre><code class=\"python\">tpl = (     '1_3_dfsf_sdfsf',     '3_11_sdfd_jfg',     '7_17_1dsd12asf sa321fs afsfffsdfs'     '11_19_dfgdfg211123sdg sdgsdgf dsfg',     '13_7_dsfgs dgfdsgdg',     '24_12_dasdsfgs dgfdsgdg', ) <\/code><\/pre>\n<p>  8. \u041f\u0440\u0438\u0440\u043e\u0434\u0430 \u0431\u0443\u043b\u0435\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430. <br \/>  True \u0438 False \u044d\u0442\u043e \u0441\u0430\u043c\u044b\u0435 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0435 1 \u0438 0, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b\u0438 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u044f\u0437\u044b\u043a\u0430.  <\/p>\n<pre><code class=\"python\">try:     print True + 10 \/ False * 3 except Exception as e:     print e  # integer division or modulo by zero <\/code><\/pre>\n<p>  7. \u0423\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f. \u041e\u043f\u0430\u0441\u043d\u0430 \u0442\u0435\u043c \u0447\u0442\u043e \u043f\u043e\u0442\u0435\u0440\u044f \u0441\u043b\u044d\u0448\u0430, \u043b\u0438\u0431\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u0432 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c \u043e\u0448\u0438\u0431\u043a\u0430\u043c. \u041a\u0430\u043a \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0440\u0443\u0433\u043b\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438.  <\/p>\n<pre><code class=\"python\">x = 1 + 2 + 3 \\ + 4 <\/code><\/pre>\n<p>  9. \u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f and, or \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0442 PHP \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 True \u0438\u043b\u0438 False, \u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u043e\u0434\u0438\u043d \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f, \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 current_lang \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442  <\/p>\n<pre><code class=\"python\">current_lang =  from_GET or from_Session or from_DB or DEFAULT_LANG <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043a\u0430\u043a \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u0442\u0435\u0440\u043d\u0430\u0440\u043d\u043e\u043c\u0443 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0443 \u0442\u0430\u043a \u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043d\u043e \u0441\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u043f\u0438\u0441\u043a\u0430 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f &#187;, 0, False, None, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0451\u043d \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438, \u0430 \u043d\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u043f\u0438\u0441\u043a\u0430.  <\/p>\n<pre><code class=\"python\"> a = ['one', 'two', 'three'] print a and a[0] or None  # one <\/code><\/pre>\n<p>  10. \u041f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0432\u0441\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0438\u043a\u0430\u043a \u0438\u0445 \u043d\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043d\u043e \u0442\u0430\u043a\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u0442\u0430\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0438 \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0430 \u0441\u0440\u0435\u0434\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445. \u0422\u0430\u043a \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435 \u0441\u0442\u043e\u0438\u0442, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u0443\u0432\u0435\u0440\u0435\u043d\u044b \u043d\u0430 100% \u0447\u0442\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u043d\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0447\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0435 \u0434\u043e\u043f\u0438\u0448\u0435\u0442 \u0432 \u0431\u043b\u043e\u043a try-except \u0441\u0442\u0440\u043e\u043a\u0443, \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0432\u0441\u0451 \u0442\u0430\u043a\u0438 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0420\u0435\u0448\u0435\u043d\u0438\u0435: \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043b\u043e\u0433, \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u0438\u0437\u0438\u0440\u0443\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0442\u0438\u043f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439, \u043e\u0431\u0440\u0430\u043c\u043b\u044f\u0439\u0442\u0435 \u0432 try-except \u043b\u0438\u0448\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043a\u0443\u0441\u043e\u043a \u043a\u043e\u0434\u0430. <\/p>\n<pre><code class=\"python\">try:     # \u041c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0442\u0435\u043c \u0445\u0443\u0436\u0435 except Exception:                                                                pass <\/code><\/pre>\n<p>  11. \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u0437 bulit-in. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u044b list, id, type. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0435 id, type \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043a\u043b\u0430\u0441\u0441 list \u0432 \u043c\u043e\u0434\u0443\u043b\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f. \u041a\u0430\u043a \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c PyLint \u0432 \u0441\u0432\u043e\u044e IDE \u0438 \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0447\u0442\u043e \u043e\u043d \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442.<\/p>\n<pre><code class=\"python\">def list(id=DEFAULT_ID, type=TYPES.ANY_TYPE):                                                                            &quot;&quot;&quot;                                                                                             W0622 Redefining built-in &quot;id&quot; [pylint]                                                         &quot;&quot;&quot;                                                                                                                                                                                             return Item.objects.filter(id=id, item_type=type)   <\/code><\/pre>\n<p>  12. \u0420\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u0434, \u0431\u0435\u0437 \u0441\u044e\u0440\u043f\u0440\u0438\u0437\u043e\u0432\u2026 \u0434\u043b\u044f \u0432\u0430\u0441\u2026 \u0410 \u0432\u043e\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0439 mod2.py \u0432\u0435\u0441\u044c\u043c\u0430 \u0443\u0434\u0438\u0432\u0438\u0442\u0441\u044f, \u0437\u0430\u043c\u0435\u0442\u0438\u0432, \u0447\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043c\u043e\u0434\u0443\u043b\u044f \u0432\u0434\u0440\u0443\u0433 \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f. \u041a\u0430\u043a \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0440\u0430\u0442\u044c\u0441\u044f \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u0438\u043b\u0438 \u0445\u043e\u0442\u044f\u0431 \u0432\u0432\u043e\u0434\u0438\u0442\u044c \u0432 mod2.py \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430. \u0422\u043e\u0433\u0434\u0430 \u0438\u0437\u0443\u0447\u0430\u044f mod2.py \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0445\u043e\u0442\u044f \u0431 \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c \u043c\u043e\u0434\u0443\u043b\u044f \u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f.<\/p>\n<pre><code class=\"python\">    # mod1.py                                                                                       import mod2                                                                                     mod2.any_attr = '123'  <\/code><\/pre>\n<p>  PS: \u041a\u0440\u0438\u0442\u0438\u043a\u0430, \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f, \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442\u0441\u044f.    \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\/192098\/\"> http:\/\/habrahabr.ru\/post\/192098\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0442\u0430\u043a\u0438\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 + \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435, \u043d\u043e \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432 \u043a\u043e\u0434\u0435 \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c. \u0421\u0442\u0430\u0442\u044c\u044f \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u0430 \u043d\u0430 python \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 \u0441 \u043e\u043f\u044b\u0442\u043e\u043c 0 \u2014 1,5 \u0433\u043e\u0434\u0430. \u041e\u043f\u044b\u0442\u043d\u044b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432 \u043a\u043e\u043c\u0435\u043d\u0442\u0430\u0445 \u043f\u043e\u043a\u0440\u0438\u0442\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u0432\u043e\u0438\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438.  <\/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-192098","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/192098","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=192098"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/192098\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=192098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=192098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=192098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}