{"id":192512,"date":"2013-09-04T12:39:03","date_gmt":"2013-09-04T08:39:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=192512"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=192512","title":{"rendered":"<span class=\"post_title\">Python. \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u043e\u0432<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0422\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u043d\u0438\u0432\u044b\u0439 \u0435\u0449\u0451 \u043d\u0435 \u043f\u0438\u0441\u0430\u043b \u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b. \u041d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u0435\u043c\u0441\u044f \u0447\u0435\u0441\u0442\u043d\u043e \u2014 \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0441\u043a\u0443\u0447\u043d\u043e. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0434\u043b\u044f legacy-\u043a\u043e\u0434\u0430. \u0421\u043e\u0442\u043d\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f, \u043e\u0434\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a. \u0421\u043a\u0443\u043a\u0430. \u0427\u0442\u043e \u0441 \u044d\u0442\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c?<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/2b4\/7a0\/211\/2b47a02117fd3575d167f8e5186ab1c9.jpg\" alt=\"image\"\/><br \/>  <sup>\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0434\u043b\u044f \u043f\u0440\u0438\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f. \u041a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u043f\u0438\u0442\u043e\u043d, \u0434\u0430?<\/sup><br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>Pythoscope<\/h4>\n<p>  \u0411\u043b\u0430\u0433\u043e, \u043c\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u2014 \u043d\u0430\u0440\u043e\u0434 \u043b\u0435\u043d\u0438\u0432\u044b\u0439, \u0433\u043e\u0442\u043e\u0432\u044b \u0443\u0431\u0438\u0442\u044c \u043f\u0430\u0440\u0443 \u043d\u0435\u0434\u0435\u043b\u044c \u0443\u0431\u0438\u0442\u044c \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u0440\u0435\u0448\u0438\u0442\u044c \u0447\u0430\u0441\u043e\u0432\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0437\u0430 \u043f\u044f\u0442\u044c \u043c\u0438\u043d\u0443\u0442. \u0422\u0430\u043a \u0447\u0442\u043e \u0437\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0438\u043d\u0443\u0442 \u0433\u0443\u0433\u043b\u0435\u043d\u0438\u044f \u0432 \u044f\u043d\u0434\u0435\u043a\u0441\u0435 \u044f \u043d\u0430\u0448\u0435\u043b \u043a\u043e\u043b\u043b\u0435\u0433 \u043f\u043e \u043d\u0435\u0441\u0447\u0430\u0441\u0442\u044c\u044e \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0435\u043d\u0438\u044e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>  \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c Pythoscope:<\/p>\n<pre><code class=\"bash\">sudo pip install Pythoscope <\/code><\/pre>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0443 stable-\u0432\u0435\u0442\u043a\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u044e\u043d\u0438\u043a\u043e\u0434\u043e\u043c. \u0414\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0446\u0435\u043b\u0435\u0439 \u0441\u043e\u0439\u0434\u0435\u0442 \u0438 \u043e\u043d\u0430, \u043d\u043e \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043b\u0443\u0447\u0448\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f dev-\u0432\u0435\u0442\u043a\u043e\u0439, \u0431\u043b\u0430\u0433\u043e \u043e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e:<\/p>\n<pre><code class=\"bash\">sudo apt-get install bzr bzr branch lp:pythoscope cd pythoscope\/ python setup.py install <\/code><\/pre>\n<\/p><\/div>\n<\/div>\n<h4>\u041f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u0442\u0430<\/h4>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/65d\/526\/c2b\/65d526c2b72c2919c20ec8c115a41309.jpg\" alt=\"image\"\/><\/p>\n<p>  \u0427\u0442\u043e \u0431\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0442\u0430, \u043d\u0430\u043c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0443\u0436\u0435\u043d \u043a\u043e\u0442. \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0435\u0433\u043e:  <\/p>\n<pre><code class=\"python\"># cat.py class Cat(object):     def __init__(self, name='Tom'):         self.name = name      def eat(self, food):         if food == 'fish':             return 'Yummy!'         else:             return 'Ugh!' <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 \u0441 cat.py \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c Pythoscope:<\/p>\n<pre><code class=\"bash\">pythoscope --init <\/code><\/pre>\n<p>  \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043f\u0430\u043f\u043a\u0443 .pythoscope, \u0433\u0434\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u0441 Pythoscope. \u0410 \u0442\u0435\u043f\u0435\u0440\u044c, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0442\u0435\u0441\u0442\u043e\u0432:<\/p>\n<pre><code class=\"bash\">pythoscope cat.py <\/code><\/pre>\n<p>  \u0423 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043f\u0430\u043f\u043a\u0430 tests \u0441 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c cat_test.py. \u0412 \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u2026 \u041f\u043e\u0447\u0442\u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u0442:<\/p>\n<pre><code class=\"python\"># tests\/cat_test.py import unittest  class TestCat(unittest.TestCase):     def test___init__(self):         # cat = Cat(name)         assert False # TODO: implement your test here      def test_eat(self):         # cat = Cat(name)         # self.assertEqual(expected, cat.eat(food))         assert False # TODO: implement your test here  if __name__ == '__main__':     unittest.main() <\/code><\/pre>\n<p>  \u041d\u0435\u0433\u0443\u0441\u0442\u043e? \u041d\u0443, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0435\u0441\u0442\u044c \u043a\u0430\u0440\u043a\u0430\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043d\u0430\u043c \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0442\u0435\u0441\u0442\u043e\u0432.<br \/>  \u041a\u0430\u043a \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u043c\u0430\u0433\u0438\u0438 \u043d\u0435 \u0431\u044b\u0432\u0430\u0435\u0442 \u2014 \u0442\u0435\u0441\u0442\u044b \u0441\u0430\u043c\u0438 \u043d\u0435 \u043d\u0430\u043f\u0438\u0448\u0443\u0442\u0441\u044f. \u041d\u043e \u043d\u0435 \u0432\u0441\u0451 \u043f\u043e\u0442\u0435\u0440\u044f\u043d\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043c\u043e\u0447\u044c Pythoscope \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0432\u043d\u044b, \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u00ab\u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430\u00bb (points of entry) \u2014 \u043d\u0435\u043a\u0438\u0435 use-case \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<p>  \u041d\u0430\u043f\u0438\u0448\u0435\u043c points of entry \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0442\u044d:<\/p>\n<pre><code class=\"python\"># .pythoscope\/points-of-entry\/eat_fish_poe.py  from cat import Cat Cat().eat('fish') <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0449\u0435 \u0440\u0430\u0437 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0442\u0435\u0441\u0442\u043e\u0432:  <\/p>\n<pre><code class=\"bash\">pythoscope cat.py <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043b\u0443\u0447\u0448\u0435, \u043a \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0441\u044f \u043c\u0435\u0442\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442:  <\/p>\n<pre><code class=\"python\"># tests\/cat_test.py ...  def test_eat_returns_Yummy_for_fish_after_creation_with_Tom(self):         cat = Cat('Tom')         self.assertEqual('Yummy!', cat.eat('fish'))  ... <\/code><\/pre>\n<p>  \u0410 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u0434\u0441\u0443\u043d\u0443\u0442\u044c \u043a\u043e\u0442\u044d \u043d\u0435 \u0440\u044b\u0431\u0443? \u041e\u0448\u0438\u0431\u043a\u0430? \u041d\u0430\u0434\u043e \u0438 \u044d\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c:  <\/p>\n<pre><code class=\"python\"># .pythoscope\/points-of-entry\/eat_tomato_poe.py  from cat import Cat Cat().eat('tomato') <\/code><\/pre>\n<p>  \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c:<\/p>\n<pre><code class=\"bash\">pythoscope cat.py <\/code><\/pre>\n<p>  \u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043b\u0438\u0448\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c:<\/p>\n<pre><code class=\"bash\">nosetests  .. ---------------------------------------------------------------------- Ran 2 tests in 0.001s  OK  <\/code><\/pre>\n<p>  \u041f\u0440\u0435\u0432\u043e\u0441\u0445\u043e\u0434\u043d\u043e! \u0423\u0434\u0430\u0447\u043d\u043e\u0433\u043e \u0438 \u043b\u0435\u0433\u043a\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f! \t\t\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\/192512\/\"> http:\/\/habrahabr.ru\/post\/192512\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0422\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u043d\u0438\u0432\u044b\u0439 \u0435\u0449\u0451 \u043d\u0435 \u043f\u0438\u0441\u0430\u043b \u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b. \u041d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u0435\u043c\u0441\u044f \u0447\u0435\u0441\u0442\u043d\u043e \u2014 \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0441\u043a\u0443\u0447\u043d\u043e. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0434\u043b\u044f legacy-\u043a\u043e\u0434\u0430. \u0421\u043e\u0442\u043d\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f, \u043e\u0434\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a. \u0421\u043a\u0443\u043a\u0430. \u0427\u0442\u043e \u0441 \u044d\u0442\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c?<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/2b4\/7a0\/211\/2b47a02117fd3575d167f8e5186ab1c9.jpg\" alt=\"image\"\/><br \/>  <sup>\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0434\u043b\u044f \u043f\u0440\u0438\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f. \u041a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u043f\u0438\u0442\u043e\u043d, \u0434\u0430?<\/sup>  <\/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-192512","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/192512","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=192512"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/192512\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=192512"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=192512"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=192512"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}