{"id":258802,"date":"2015-06-07T03:13:02","date_gmt":"2015-06-06T23:13:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=258802"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=258802","title":{"rendered":"Python \u0438 D"},"content":{"rendered":"<p>     \t\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a, \u0445\u0430\u0431\u0440!<\/p>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0430\u0442\u044c \u043e \u043f\u043b\u044e\u0441\u0430\u0445 \u0438 \u043c\u0438\u043d\u0443\u0441\u0430\u0445 \u044f\u0437\u044b\u043a\u043e\u0432.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/c1b\/779\/c3b\/c1b779c3b4bb4c44816e9dd98a88b2bc.png\"\/><\/p>\n<p>  \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432\u043c\u0435\u0441\u0442\u0435!<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/603\/3fa\/ca4\/6033faca468c4c6ba6c44ce6313d1f76.png\"\/><\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <a href=\"https:\/\/github.com\/ariovistus\/pyd\">pyd<\/a>. \u0421 \u0435\u0451 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u043a\u0430\u043a \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u043d\u0430 python \u0438\u0437 \u043a\u043e\u0434\u0430 \u043d\u0430 d, \u0442\u0430\u043a \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442.<\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442. \u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0444\u0430\u0439\u043b dub.json  <\/p>\n<pre><code class=\"javascript\">{     &quot;name&quot;: &quot;pydtest&quot;, \t&quot;targetType&quot;: &quot;executable&quot;, \t&quot;dependencies&quot;: {         &quot;pyd&quot;: &quot;~&gt;0.9.7&quot; \t},     &quot;subConfigurations&quot;: {         &quot;pyd&quot;: &quot;python34&quot;     } } <\/code><\/pre>\n<p>  subConfigurations \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c python 3.4<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0451\u043c source\/main.d  <\/p>\n<pre><code class=\"cpp\">import std.stdio; import pyd.pyd, pyd.embedded;  void main() {     py_init();      auto script = new InterpContext;     \/\/ \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 2 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0438\u0441\u043a\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u0438 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438     \/\/ \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043f\u0430\u043a\u0435\u0442 myscript.py \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443      script.py_stmts( &quot;import sys&quot; );     script.py_stmts( &quot;sys.path.append('.')&quot; );      script.py_stmts( &quot;import myscript&quot; );      writeln( script.py_eval!string( &quot;myscript.func()&quot; ) ~ &quot; from pyd&quot; ); } <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0451\u043c myscript.py  <\/p>\n<pre><code class=\"python\">def func():     return &quot;hello habr!&quot; <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0431\u043e\u0440\u043a\u0443 \u0438 \u0435\u0451 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442  <\/p>\n<pre><code class=\"bash\">dub build && .\/pydtest <\/code><\/pre>\n<p>  \u0418 \u0432\u0441\u0451!  <\/p>\n<pre><code class=\"bash\">hello habr! from pyd <\/code><\/pre>\n<p>  \u0412\u0441\u0451 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u043e!<\/p>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u0442\u044c. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0432 myscript.py  <\/p>\n<pre><code class=\"python\">def sum(a,b):     return a + b <\/code><\/pre>\n<p>  \u0418 \u0432\u044b\u0437\u043e\u0432\u0435\u043c \u0435\u0451 \u0438\u0437 \u043a\u043e\u0434\u0430 \u043d\u0430 D. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u044d\u0442\u043e \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e main.main  <\/p>\n<pre><code class=\"cpp\">...     script.x = 13;     script.y = 21;      writefln( &quot;result: %d&quot;, script.py_eval!int( &quot;myscript.sum(x,y)&quot; ) ); ... <\/code><\/pre>\n<p>  \u0423\u0441\u043b\u043e\u0436\u043d\u0438\u0442\u044c \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c =)<br \/>  \u041a\u043b\u0430\u0441\u0441 InterpContext \u043e\u043b\u0438\u0446\u0435\u0442\u0432\u043e\u0440\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430 (\u043a\u0430\u043a \u043d\u0438 \u0441\u0442\u0440\u0430\u043d\u043d\u043e) \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0443\u0434\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0442\u0430\u043a\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c. \u041f\u043e\u043b\u044f x \u0438 y \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 script \u2014 \u0442\u0430\u043a\u0438\u0445 \u043f\u043e\u043b\u0435\u0439 \u043d\u0435\u0442, \u043d\u043e \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0432 \u044f\u0437\u044b\u043a\u0435 D \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u044b \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430 (\u0438\u043b\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b) \u0432 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 opDispatch, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043a\u0430\u043a \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u043c\u0435\u0442\u043e\u0434\u0430 InterpContext.opDispatch<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">   @property PydObject opDispatch(string id)() { \/\/ \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430         return this.locals[id];     }      @property void opDispatch(string id, T)(T t) { \/\/ \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442         static if(is(T == PydObject)) {             alias t s;         }else{             PydObject s = py(t);         }         this.locals[id] = py(s);     } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0430\u043a\u0438\u043c \u0436\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0437\u044f\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430:  <\/p>\n<pre><code class=\"cpp\">...     script.py_stmts( &quot;z = myscript.sum(8,7)&quot; );     writefln( &quot;result2: %d&quot;, script.z.to_d!int ); ... <\/code><\/pre>\n<p>  \u0414\u0430 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0430\u043a \u0436\u0435:  <\/p>\n<pre><code class=\"cpp\">...     auto sum = script.myscript.sum;     writefln( &quot;result3: %d&quot;, sum(14,15).to_d!int ); ... <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b<\/b><\/p>\n<div class=\"spoiler_text\">\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 property \u0432 \u044f\u0437\u044b\u043a\u0435 D \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"http:\/\/wiki.dlang.org\/Property_Discussion_Wrap-up\">\u0434\u0430\u0432\u043d\u043e \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u0435\u043c\u043e\u0439 \u0442\u0435\u043c\u043e\u0439<\/a>, \u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0432\u043e\u043f\u0440\u043e\u0441 \u0441\u0432\u044f\u0437\u0430\u043d \u0441 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0435\u0439, \u043a\u043e\u0433\u0434\u0430 property \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c opCall  <\/p>\n<pre><code class=\"cpp\">script.myscript.sum(14,15).to_d!int; \/\/ \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0447\u0442\u043e \u0441\u0442\u0440\u0430\u043d\u043d\u043e, \u0431\u044b\u043b\u043e \u0431\u044b \u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0437\u0430\u043f\u0440\u0435\u0442\u0438\u0442\u044c script.myscript.oneargfunc(12).to_d!int; \/\/ \u043d\u0435 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0442\u0430\u043a \u043a\u0430\u043a oneargfunc(12) \u044d\u0442\u043e \u0432\u044b\u0437\u043e\u0432 opDispatch \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c 12 script.myscript.oneargfunc()(12).to_d!int; \/\/ \u0442\u0443\u0442 \u0432\u0441\u0451 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435: \u044f\u0432\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f oneargfunc(), \u0437\u0430\u0442\u0435\u043c \u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f opCall(12) <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 \u0438\u0437 \u043a\u043e\u0434\u0430 \u043d\u0430 python \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u043d\u0430 D. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u0443\u044e \u043f\u0430\u043f\u043a\u0443 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e.<br \/>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b dcode.d \u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435\u043c:  <\/p>\n<pre><code class=\"cpp\">module dcode;  import pyd.pyd; import std.math;  float[] calc( float x, float y ) {     return [ sqrt(x*y), x^^y, x\/y ]; }  extern(C) void PydMain() {     def!(calc)();     module_init(); } <\/code><\/pre>\n<p>  \u0438 \u0444\u0430\u0439\u043b setup_my_dcode.py (\u0438\u043c\u044f \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442)  <\/p>\n<pre><code class=\"python\">from pyd.support import setup, Extension projName = 'dcode' setup(     name=projName,     version='0.1',     ext_modules=[         Extension(projName, ['dcode.d'],             extra_compile_args=['-w'],             build_deimos=True,             d_lump=True         )     ], ) <\/code><\/pre>\n<p>  \u0441\u043e\u0431\u0435\u0440\u0451\u043c \u043d\u0430\u0448\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 (\u0438\u043c\u0435\u043d\u043d\u043e build, \u0430 \u043d\u0435 install, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0441\u043e\u0440\u044f\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u043c\u0438 \u0444\u0430\u0439\u043b\u0430\u043c\u0438)  <\/p>\n<pre><code class=\"bash\">python3 setup_my_dcode.py build <\/code><\/pre>\n<p>  \u0441\u043e\u0437\u0434\u0430\u0441\u0442\u044c\u0441\u044f \u043f\u0430\u043f\u043e\u0447\u043a\u0430 build \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f  <\/p>\n<pre><code class=\"bash\">build \u251c\u2500\u2500 lib.linux-x86_64-3.4 \u2502\u00a0\u00a0 \u2514\u2500\u2500 dcode.cpython-34m.so \u2514\u2500\u2500 temp.linux-x86_64-3.4     \u2514\u2500\u2500 infra         \u251c\u2500\u2500 pydmain.d         \u251c\u2500\u2500 so_ctor.o         \u2514\u2500\u2500 temp.o <\/code><\/pre>\n<p>  \u041d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 build\/lib.linux-x86_64-3.4\/dcode.cpython-34m.so. \u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e \u0432 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 \u0441 \u043d\u0438\u043c \u0438 \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0432 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0435:  <\/p>\n<pre><code class=\"python\">python3 Python 3.4.1 (default, Nov  3 2014, 14:38:10)  [GCC 4.9.1 20140930 (Red Hat 4.9.1-11)] on linux Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information. &gt;&gt;&gt; import dcode &gt;&gt;&gt; dcode.calc( 5, 12 ) [7.745966911315918, 244140624.0, 0.4166666567325592] &gt;&gt;&gt;  <\/code><\/pre>\n<p>  \u0418 \u043e\u043f\u044f\u0442\u044c \u0432\u0441\u0451 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e!<\/p>\n<p>  \u0418 \u043e\u043f\u044f\u0442\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u0441\u0451 \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u0442\u044c \u2014 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043b\u0430\u0441\u0441 \u0432 dcode.d  <\/p>\n<pre><code class=\"cpp\">class Foo {     float a = 0, b = 0;     static string desc() { return &quot;some ops&quot;; }     this( float A, float B ) { a = A; b = B; }     float sum() const { return a + b; }     float div() const { return a \/ b; } }  extern(C) void PydMain() {     def!(calc)(); \/\/ \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438     module_init(); \/\/ \u0437\u0430\u0442\u0435\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u044f     wrap_class!( \/\/ \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u044b         Foo,         Init!(float,float),         Repr!(Foo.toString), \/\/ \u043a\u0430\u043a python \u0431\u0443\u0434\u0435\u0442 \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u0432 \u0441\u0442\u0440\u043e\u043a\u0443         Def!(Foo.sum),         Def!(Foo.div),         StaticDef!(Foo.desc)     )(); } <\/code><\/pre>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u0432 \u044d\u0442\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0432\u0441\u0451 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u043b\u043e\u0441\u044c. \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 D \u0432 python \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b, \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0438 \u0442.\u0434.<br \/>  \u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c:  <\/p>\n<pre><code class=\"python\">python3 Python 3.4.1 (default, Nov  3 2014, 14:38:10)  [GCC 4.9.1 20140930 (Red Hat 4.9.1-11)] on linux Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information. &gt;&gt;&gt; from dcode import Foo &gt;&gt;&gt; Foo.desc() 'some ops' &gt;&gt;&gt; a = Foo(1,2) &gt;&gt;&gt; a.div() 0.5 &gt;&gt;&gt; a.sum() 3.0 &gt;&gt;&gt;  <\/code><\/pre>\n<p>  \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442!<\/p>\n<p>  \u041e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e: \u0438\u0445 \u043c\u043d\u043e\u0433\u043e \u0438 \u043e\u043d\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b. \u0421\u0442\u043e\u0438\u0442 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c, \u0447\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0435\u0449\u0451 \u043d\u0435 \u0434\u043e\u0448\u043b\u0430 \u0434\u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 1.0.0 \u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0438. <br \/>  \u042f \u043d\u0430\u0448\u0451\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443: \u043d\u0435\u043b\u044c\u0437\u044f \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u0434 \u043d\u0430 D \u0438\u0437 \u043a\u043e\u0434\u0430 \u043d\u0430 python, \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u0432 \u043a\u043e\u0434 \u043d\u0430 D<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/bf9\/07e\/37e\/bf907e37e4ea458086d5c734719f1b62.jpg\"\/><br \/>  \u041d\u043e \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u043d\u0435 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0438 \u0430\u0432\u0442\u043e\u0440 \u0435\u0451 \u0441\u043c\u043e\u0436\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c.<\/p>\n<p>  \u041e\u0447\u0435\u043d\u044c \u043f\u0440\u0438\u044f\u0442\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043f\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0443 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f <a href=\"http:\/\/pyd.readthedocs.org\/en\/latest\/extend.html\">\u0437\u0434\u0435\u0441\u044c<\/a> \u0438 \u0435\u0449\u0451 \u043f\u0440\u0438\u043c\u0435\u0440\u044b <a href=\"https:\/\/github.com\/ariovistus\/pyd\/tree\/master\/examples\">\u0437\u0434\u0435\u0441\u044c<\/a>     \t<\/p>\n<div class=\"clear\"><\/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\/259727\/\"> http:\/\/habrahabr.ru\/post\/259727\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a, \u0445\u0430\u0431\u0440!<\/p>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0430\u0442\u044c \u043e \u043f\u043b\u044e\u0441\u0430\u0445 \u0438 \u043c\u0438\u043d\u0443\u0441\u0430\u0445 \u044f\u0437\u044b\u043a\u043e\u0432.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/c1b\/779\/c3b\/c1b779c3b4bb4c44816e9dd98a88b2bc.png\"\/><\/p>\n<p>  \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432\u043c\u0435\u0441\u0442\u0435!<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/603\/3fa\/ca4\/6033faca468c4c6ba6c44ce6313d1f76.png\"\/><\/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-258802","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/258802","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=258802"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/258802\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=258802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=258802"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=258802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}