{"id":455602,"date":"2025-04-11T09:19:54","date_gmt":"2025-04-11T09:19:54","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=455602"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=455602","title":{"rendered":"<span>\u0413\u0430\u0439\u0434 \u043f\u043e overload: \u043a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u043a\u043e\u0434 \u043d\u0430 Python \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0431\u044d\u043a\u0435\u043d\u0434\u043e\u0432<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0447\u0430\u0441\u0442\u043e \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0441 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0434\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u0427\u0442\u043e\u0431\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 (overload). \u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0438\u043c\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0439 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0435 \u043e\u0434\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0434 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u0434 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u044b\u043c \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c.\u00a0<\/p>\n<p>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u0432 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0412 \u043a\u043e\u043d\u0446\u0435 \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0438 \u0437\u0430\u0447\u0435\u043c \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u043d\u0430 Python \u0441\u0432\u043e\u0438\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ccb\/c15\/984\/ccbc159846c5ec94520abe8a6247bdb1.png\" width=\"1189\" height=\"1446\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/ccb\/c15\/984\/ccbc159846c5ec94520abe8a6247bdb1.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ccb\/c15\/984\/ccbc159846c5ec94520abe8a6247bdb1.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/h3>\n<p>\u041f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 (function overloading) \u2014 \u044d\u0442\u043e \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c, \u043d\u043e \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430\u043c\u0438: \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c, \u0442\u0438\u043f\u0430\u043c\u0438 \u0438\u043b\u0438 \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432.\u00a0<\/p>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u042d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0441\u0442\u0440\u043e\u0433\u043e \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445, \u0447\u0442\u043e\u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u0433\u0438\u0431\u043a\u0438\u0439 \u0438 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u043a\u043e\u0434 \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0449\u0435.<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 C++ \u0438 Typescript<\/h4>\n<p>C++ \u2014 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u044f\u0437\u044b\u043a\u0430 \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u00ab\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438\u00bb. \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c sum, \u043d\u043e \u0441 \u0440\u0430\u0437\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432\u00a0\u2014 <code>int<\/code> \u0438 <code>double<\/code>:<\/p>\n<pre><code class=\"cpp\">#include &lt;iostream&gt; #include &lt;string&gt;  int sum(int a, int b) {     return a + b; }  double sum(double a, double b) {     return a + b; }  int main() {     std::cout &lt;&lt; sum(2, 3) &lt;&lt; std::endl;     \/\/ \u0412\u044b\u0437\u043e\u0432\u0435\u0442 sum(int, int)     std::cout &lt;&lt; sum(2.5, 3.1) &lt;&lt; std::endl; \/\/ \u0412\u044b\u0437\u043e\u0432\u0435\u0442 sum(double, double)     return 0; }<\/code><\/pre>\n<p>\u0412 TypeScript \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0442\u0438\u043f\u043e\u0432. \u0417\u0434\u0435\u0441\u044c \u0434\u0432\u0435 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u044b \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 greet, \u0430 \u0441\u0430\u043c\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0434\u043d\u0430. \u041e\u043d\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u043a\u0430\u043a\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u0440\u0438\u0448\u043b\u0438:<\/p>\n<pre><code class=\"typescript\">function greet(name: string): string; function greet(name: string, age: number): string; function greet(name: string, age?: number): string {   if (age !== undefined) {     return `Hello, ${name}! You are ${age} years old.`;   } else {     return `Hello, ${name}!`;   } }  console.log(greet(\"Alice\"));       \/\/ \"Hello, Alice!\" console.log(greet(\"Bob\", 30));     \/\/ \"Hello, Bob! You are 30 years old.\" <\/code><\/pre>\n<p><strong>\u041f\u043e\u0447\u0435\u043c\u0443 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 \u0447\u0438\u0441\u0442\u043e\u043c \u0432\u0438\u0434\u0435 \u043d\u0435\u0442 \u0432 Python \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445?<\/strong><\/p>\n<p>Python \u2014 \u044f\u0437\u044b\u043a \u0441 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0435\u0439. \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043b\u044e\u0431\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u043e\u0447\u0442\u0438 \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u00ab\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f\u00bb \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u0438\u0434\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435.\u00a0<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 Python \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c, \u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u00ab\u0437\u0430\u0442\u0440\u0435\u0442\u00bb \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0443\u044e:<\/p>\n<pre><code class=\"python\">def hello(name: str):     print(f\"Hello {name}\")  def hello(age: int):     print(f\"Your age is {age}\")  hello(\"Alice\")  # \"Your age is Alice\" \u2013 \u043e\u0448\u0438\u0431\u043a\u0430: \u0432\u044b\u0437\u043e\u0432\u0435\u0442\u0441\u044f \u0432\u0442\u043e\u0440\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f, \u043d\u043e \u043e\u043d\u0430 \u0436\u0434\u0451\u0442 int.<\/code><\/pre>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 Python \u043d\u0435\u0442. \u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 (:<\/p>\n<h4>\u041a\u0430\u043a \u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u0432 Python?<\/h4>\n<p>\u041d\u0438\u0436\u0435 \u043e\u043f\u0438\u0448\u0443 \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c Python-\u043a\u043e\u0434\u0435. \u041f\u0435\u0440\u0432\u044b\u0439 \u2014 \u0441\u0430\u043c\u044b\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u2014 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p><strong>1. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0442\u0438\u043f\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/strong><\/p>\n<pre><code class=\"python\">def hello(name_or_age):     if isinstance(name_or_age, str):         print(f\"Hello {name_or_age}\")     elif isinstance(name_or_age, int):         print(f\"Your age is {name_or_age}\")     else:         raise TypeError(\"Expected str or int\")<\/code><\/pre>\n<p>\u041c\u0438\u043d\u0443\u0441 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u2014 \u0435\u0434\u0438\u043d\u0430\u044f \u043c\u043e\u043d\u043e\u043b\u0438\u0442\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0437\u0434\u0443\u0442\u044c\u0441\u044f \u0438 \u0441\u0442\u0430\u0442\u044c \u043d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0439. \u0410 \u0435\u0449\u0435 \u043e\u043d\u0430 \u043d\u0435 \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0435\u0440\u0441\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430\u043c\u0438.<\/p>\n<p><strong>2. \u0423\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438:<\/strong><\/p>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<pre><code class=\"python\">def hello_str(name):     print(f\"Hello {name}\")  def hello_int(age):     print(f\"Your age is {age}\")<\/code><\/pre>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442 \u0438 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u0435\u043d, \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0433\u043e \u0443\u0434\u043e\u0431\u043d\u044b\u043c \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u0433\u0434\u0435 \u0432\u0430\u0436\u043d\u0430 \u044f\u0432\u043d\u043e\u0441\u0442\u044c. \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 \u043a\u043e\u0434\u0435 \u0438 \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435\u0442 \u0435\u0434\u0438\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043f\u043e\u0445\u043e\u0436\u0438\u043c\u0438 \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0438 \u043c\u043e\u0436\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c API \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u043c.<\/p>\n<p><strong>3. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 <\/strong><code><strong>functools.singledispatch<\/strong><\/code><strong> (\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0441 Python 3.4):<\/strong><\/p>\n<pre><code class=\"python\">from functools import singledispatch  @singledispatch def hello(arg):     raise TypeError(\"Unsupported type\")  @hello.register def _(arg: str):     print(f\"Hello {arg}\")  @hello.register def _(arg: int):     print(f\"Your age is {arg}\") <\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u041d\u043e <code>singledispatch<\/code> \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u043d\u0430 \u0442\u0438\u043f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430, \u0430 \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, <code>Union<\/code>, <code>Optional<\/code> \u0438 \u0442. \u0434.) \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e.<\/p>\n<p><strong>4. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <\/strong><code><strong>multipledispatch<\/strong><\/code><strong>:<\/strong><\/p>\n<pre><code class=\"python\">from multipledispatch import dispatch  @dispatch(str) def hello(arg):     print(f\"Hello {arg}\")  @dispatch(int) def hello(arg):     print(f\"Your age is {arg}\")<\/code><\/pre>\n<p>\u042d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440, \u043d\u043e \u043e\u043d\u0430 \u043d\u0435 \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 Python \u2014 \u0442\u0430\u043a \u0447\u0442\u043e \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0435\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043e\u043d\u0430 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u043e\u0432.<\/p>\n<p><strong>5. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a<\/strong><\/p>\n<p>\u041d\u0435\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438\u043b\u0438 \u0441\u0430\u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u044b\u0442\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u044b \u0447\u0435\u0440\u0435\u0437 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0434\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u0435\u0441\u0442\u0430\u0445. \u0418\u043c\u0435\u043d\u043d\u043e \u0432 \u044d\u0442\u0443 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e \u0438 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u0432 \u0432\u043e\u043f\u0440\u043e\u0441\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f.<\/p>\n<h3>\u041a\u0430\u043a \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 Python<\/h3>\n<p>\u041c\u044b \u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u043f\u0440\u0438\u0448\u043b\u0438 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043d\u0435\u0442 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043d\u0430\u043c \u043f\u043e\u0434\u043e\u0448\u0435\u043b. \u041e\u043d\u0438:<\/p>\n<ul>\n<li>\n<p>\u0438\u043c\u0435\u044e\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u044e\u0442\u0441\u044f<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u0443\u043c\u0435\u044e\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 generic&#8217;\u0430\u043c\u0438 \u043f\u043e \u0442\u0438\u043f\u0443 Union, Optional, \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0441 args, **kwargs.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430\u0448\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0435 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043f\u043e\u0434 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043d\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043d\u0430\u0448\u0438 \u0442\u0435\u0445\u043d\u0438\u043a\u0438: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, LazyImport. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u0438 \u043a\u043e\u043b\u043b\u0435\u0433\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u044b (:<\/p>\n<p>\u041d\u0430\u0448\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u2014 <code>OverloadManager<\/code>, <code>OverloadFunction<\/code>, \u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 <code>@overload<\/code>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c, \u043a\u0430\u043a \u043e\u043d\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u0438 \u0440\u0435\u0448\u0430\u044e\u0442 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438.<\/p>\n<blockquote>\n<p><strong>\u0412\u0430\u0436\u043d\u043e:<\/strong> \u041d\u0430\u0448\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f <code>overload<\/code> \u2014 \u044d\u0442\u043e \u043d\u0435 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e <code>@overload<\/code> \u0438\u0437 <code>typing<\/code>. \u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0438\u0437 <code>typing<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 runtime-\u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043d\u0430\u0448\u0430 \u0432\u0435\u0440\u0441\u0438\u044f \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0430 \u043d\u0430 <strong>\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0432\u044b\u0437\u043e\u0432\u043e\u0432<\/strong> \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0442\u0438\u043f\u043e\u0432 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432.  <\/p>\n<\/blockquote>\n<p><strong>1. \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 (<\/strong><code><strong>OverloadManager.register<\/strong><\/code><strong>)<\/strong><\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 <code>@overload<\/code> \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043e\u043d\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 <code>OverloadManager<\/code>. \u0417\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0430\u0436\u043d\u044b\u0439 \u0448\u0430\u0433 \u2014 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<details class=\"spoiler\">\n<summary>\u041e\u0442\u043b\u0438\u0447\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0442 \u043c\u0435\u0442\u043e\u0434\u0430<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>__qualname__<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0435 \u0438\u043c\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<ul>\n<li>\n<p>\u0414\u043b\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438: <code>__qualname__ = \"process\"<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u043a\u043b\u0430\u0441\u0441\u0430: <code>__qualname__ = \"MyClass.process\"<\/code>.<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/details>\n<p>\u0415\u0441\u043b\u0438 \u0432 <code><strong>__qualname__<\/strong><\/code> \u0435\u0441\u0442\u044c \u0442\u043e\u0447\u043a\u0430 (<code>.<\/code>), \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u2014 \u043c\u0435\u0442\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430. \u0422\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0438\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435 <code>self.methods<\/code> \u0441 \u043a\u043b\u044e\u0447\u043e\u043c <code>(module, class_name, method_name)<\/code>. \u0414\u043b\u044f \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u043c\u044f \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435 <code>self.functions<\/code>.<\/p>\n<p><strong>\u0417\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e? <\/strong>\u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f (\u0447\u0435\u0440\u0435\u0437 <code><strong>__mro__<\/strong><\/code>, \u043e \u0447\u0435\u043c \u043d\u0438\u0436\u0435).<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/435\/2ce\/e99\/4352cee9997e386b89c729a812ca9751.png\" alt=\"\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432\" title=\"\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432\" width=\"3372\" height=\"732\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/435\/2ce\/e99\/4352cee9997e386b89c729a812ca9751.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/435\/2ce\/e99\/4352cee9997e386b89c729a812ca9751.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432<\/figcaption><\/div>\n<\/figure>\n<p><strong>2. \u0410\u043d\u0430\u043b\u0438\u0437 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b (<\/strong><code><strong>OverloadFunction.register<\/strong><\/code><strong>)<\/strong><\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043c\u044b \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443. \u0410\u043d\u0430\u043b\u0438\u0437 \u0440\u0430\u0437\u0431\u0438\u0442 \u043d\u0430 \u044d\u0442\u0430\u043f\u044b:<\/p>\n<ul>\n<li>\n<p><strong>\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <code>inspect.signature<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 <code>Signature<\/code>. \u041c\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043cc\u044f \u043f\u043e \u0432\u0441\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c \u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0438\u0445 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u043e\u0432, \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f <code>*args<\/code> \u0438 <code>**kwargs<\/code> (\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432), \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0438 \u043d\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 \u0441\u0442\u0440\u043e\u0433\u043e\u0439 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0435. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u2014 \u043a\u043e\u0440\u0442\u0435\u0436 \u0442\u0438\u043f\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: <code>(int, str)<\/code>.<\/p>\n<ul>\n<li>\n<p><strong>\u041d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 (<\/strong><code><strong>_normalize_annotation<\/strong><\/code><strong>)<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>Union[int, str]<\/code>, <code>List[str]<\/code>, <code>Optional[float]<\/code>), \u0438 \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0443\u0434\u043e\u0431\u043d\u043e\u043c\u0443 \u0432\u0438\u0434\u0443:<\/p>\n<ul>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 <code>Union<\/code>: \u0415\u0441\u043b\u0438 \u0442\u0438\u043f \u2014 <code>Union<\/code>, \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>get_origin<\/code> (\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>Union<\/code>) \u0438 <code>get_args<\/code> (\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>(int, str)<\/code>), \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u043f\u043e\u0434\u0442\u0438\u043f\u044b \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 generic-\u0442\u0438\u043f\u043e\u0432: \u0414\u043b\u044f <code>List[str]<\/code> <code>get_origin<\/code> \u0432\u0435\u0440\u043d\u0435\u0442 <code>list<\/code>, \u0430 <code>get_args<\/code> \u2014 <code>(str,)<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u041b\u0435\u043d\u0438\u0432\u044b\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u044b: \u0415\u0441\u043b\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u2014 \u043e\u0431\u044a\u0435\u043a\u0442 <code>LazyImport<\/code>, \u043c\u044b \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0435\u0451 \u0432 <code>LazyTypeWrapper<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043b\u043e\u0436\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0432\u044b\u0437\u043e\u0432\u0430.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><strong>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435 <code>self.overloads<\/code> \u0441 \u043a\u043b\u044e\u0447\u043e\u043c \u2014 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u043c \u0442\u0438\u043f\u043e\u0432, \u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u2014 \u0441\u0430\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439.<\/p>\n<pre><code class=\"python\">class OverloadFunction:     def __init__(self, name: str):         self.name = name         self.overloads = {}      def register(self, func) -&gt; None:         # \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432         # \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439         # \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u0440\u0442\u0435\u0436\u0430 param_types                  self.overloads[param_types] = func <\/code><\/pre>\n<p><strong>3. \u0412\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (<\/strong><code><strong>OverloadFunction.__call__<\/strong><\/code><strong>)<\/strong><\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c, \u043a\u0430\u043a\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430, \u043f\u043e \u0442\u0430\u043a\u043e\u043c\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443:<\/p>\n<ul>\n<li>\n<p><strong>\u0421\u0431\u043e\u0440 \u0442\u0438\u043f\u043e\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 <code>(args)<\/code> \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u0440\u0442\u0435\u0436 \u0438\u0445 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>tuple(type(arg) for arg in args)<\/code>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b\u0437\u043e\u0432 <code>process(42, \"hello\")<\/code> \u0434\u0430\u0435\u0442 <code>(int, str)<\/code>.<\/p>\n<ul>\n<li>\n<p><strong>\u0421\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 (<\/strong><code><strong>_match_types<\/strong><\/code><strong>)<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u043e \u0441\u0435\u0440\u0434\u0446\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u0433\u0434\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0442\u0438\u043f\u044b \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0441 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432:<\/p>\n<ul>\n<li>\n<p><strong>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0434\u043b\u0438\u043d\u044b: <\/strong>\u0415\u0441\u043b\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u044d\u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u041c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432:<\/strong> \u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u2014 <code>self<\/code> (\u043f\u0443\u0441\u0442\u0430\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f), \u043e\u043d \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b.<\/p>\n<\/li>\n<li>\n<p><strong>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 <\/strong><code><strong>Union<\/strong><\/code><strong>:<\/strong> \u0415\u0441\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f <code>Union[int, str]<\/code>, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>get_args<\/code> \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f <code>(int, str)<\/code> \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0442\u0438\u043f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u043e\u043c \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445 \u0447\u0435\u0440\u0435\u0437 <code>issubclass<\/code>. \u0415\u0441\u043b\u0438 \u0432 <code>Union<\/code> \u0435\u0441\u0442\u044c <code>None<\/code>, \u043e\u043d \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u0435\u0441\u043b\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043d\u0435 <code>None<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>\u041b\u0435\u043d\u0438\u0432\u044b\u0435 \u0442\u0438\u043f\u044b:<\/strong> \u0414\u043b\u044f <code>LazyTypeWrapper<\/code> \u043c\u044b \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0442\u0438\u043f \u0447\u0435\u0440\u0435\u0437 <code>resolve()<\/code>. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u0443\u0434\u0430\u0435\u0442\u0441\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0437-\u0437\u0430 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0430), \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0438\u043c\u0435\u043d\u0430 \u0442\u0438\u043f\u043e\u0432 \u043a\u0430\u043a \u0437\u0430\u043f\u0430\u0441\u043d\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442.<\/p>\n<\/li>\n<li>\n<p><strong>Generic-\u0442\u0438\u043f\u044b:<\/strong> \u0415\u0441\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u2014 <code>list<\/code>, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u043e\u043c <code>list<\/code> (\u0447\u0435\u0440\u0435\u0437 <code>issubclass<\/code>).<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><strong>\u0412\u044b\u0431\u043e\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0438\u043f\u044b \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>inspect.signature(fn).bind_partial<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e), \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<pre><code class=\"python\">class OverloadFunction:     ...      # \u0412\u044b\u0437\u043e\u0432 \u043e\u0431\u0435\u0440\u0442\u043a\u0438 \u043d\u0430\u0434 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439     def __call__(self, *args, **kwargs) -&gt; Any:         arg_types = # \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0438\u043f\u044b \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437 args          # \u041f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e \u0432\u0441\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0432 self.overloads, \u0435\u0441\u043b\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443,         # \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:           return fn(*bound_args.args, **bound_args.kwargs)          # \u0438\u043d\u0430\u0447\u0435:           raise TypeError(f\"No match for types {arg_types}\")<\/code><\/pre>\n<p><strong>4. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f (<\/strong><code><strong>OverloadManager.call<\/strong><\/code><strong>)<\/strong><\/p>\n<p>\u0414\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043c\u044b \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<blockquote>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u2014 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430, \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0435\u0433\u043e \u0442\u0438\u043f \u0447\u0435\u0440\u0435\u0437 <code><strong>__class__<\/strong><\/code> \u0438 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0446\u0435\u043f\u043e\u0447\u043a\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 (<code>__mro__<\/code>). \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 <code>Base<\/code>, \u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 <code>Derived<\/code>, \u043c\u044b \u043d\u0430\u0439\u0434\u0435\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e.<\/p>\n<\/blockquote>\n<pre><code class=\"python\">class OverloadManager:     ...      # \u041c\u0435\u0442\u043e\u0434 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430     def call(self, name, *args, **kwargs) -&gt; Any:       # \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u0441\u0440\u0435\u0434\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439       # \u0435\u0441\u043b\u0438 \u043d\u0430\u0448\u043b\u0430\u0441\u044c, \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c:         return self.functions[name](*args, **kwargs)              # \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u044d\u0442\u043e __class__,       # \u0442\u043e \u0438\u0449\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 \u0438 \u0441\u0440\u0435\u0434\u0438 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432,       # \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u044f \u0438 \u043a\u043b\u0430\u0441\u0441\u0430, \u0437\u0430\u0442\u0435\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c:         key = (module_name, class_name, name)         return self.methods[key](*args, **kwargs)              # \u0438\u043d\u0430\u0447\u0435:         raise TypeError(f\"No overloaded function '{name}' found.\")<\/code><\/pre>\n<p><strong>\u0418\u0442\u043e\u0433\u043e\u0432\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/strong><\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/039\/b12\/119\/039b121198b5bbf9770c75377405e81e.png\" alt=\"\u0412\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438\" title=\"\u0412\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438\" width=\"4090\" height=\"658\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/039\/b12\/119\/039b121198b5bbf9770c75377405e81e.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/039\/b12\/119\/039b121198b5bbf9770c75377405e81e.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0412\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/figcaption><\/div>\n<\/figure>\n<h4>\u0427\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0438\u0442\u043e\u0433\u0435<\/h4>\n<pre><code class=\"python\">from typing import Union, Optional from copy import deepcopy  import pandas as pd import numpy as np from sklearn.datasets import load_iris from sklearn.linear_model import LogisticRegression  from my_library.overloading import overload  # \u0444\u0443\u043d\u043a\u0446\u0438\u044f-\u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438  DataFrame = Union[pd.DataFrame, np.ndarray] DataArray = Union[pd.Series, pd.Index, np.ndarray, list, tuple]  class Dataset:     \"\u041a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438\"      def __init__(self, data: DataFrame, target_column: str):         self.data = data         self.target_column = target_column         ...  class Model:     \"\u041a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439\"     def __init__(self, model):         self.model = model         self.features = None          @overload     def fit(self, dataset: Dataset, features: Optional[DataArray] = None, **kwargs):         self.features = (             self._get_features(dataset.data, dataset.target_column)             if features is None             else features         )         return self.fit(dataset.data[self.features], dataset.data[dataset.target_column], **kwargs)      @overload     def fit(self, X: DataFrame, y: DataArray, **kwargs):         self.features = self._get_features(X, None)         self.model.fit(X, y, **kwargs)         return self      @overload     def predict(self, dataset: Dataset, **kwargs):         return self.predict(dataset.data[self.features], **kwargs)      @overload     def predict(self, X: DataFrame, **kwargs):         return self.model.predict(X, **kwargs)          def _get_features(self, data: DataFrame, target_col: Optional[str]) -&gt; list:         if hasattr(data, 'columns'):             if target_col is not None:                 return data.columns.drop(target_col).tolist()             return data.columns.tolist()         else:             return list(range(data.shape[1] - (1 if target_col is None else 0)))   X, y = load_iris(as_frame=True, return_X_y=True) dataset = Dataset(pd.concat([X, y], axis=1), 'target') sklearn_model = LogisticRegression(solver='liblinear', multi_class='ovr', random_state=42)  # \u041f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0438\u043f\u043e\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 features = ['sepal length (cm)', 'sepal width (cm)', 'petal length (cm)', 'petal width (cm)'] model1.fit(dataset, features) model2.fit(dataset) model3.fit(X, y)  # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e np.array_equal(     model1.predict(dataset),      model2.predict(dataset) ) # True np.array_equal(     model2.predict(dataset),      model3.predict(dataset) ) # True np.array_equal(     model1.predict(dataset),      model1.predict(X) ) # True<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430.<\/p>\n<blockquote>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u043d\u0430\u0448\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u043e\u0431\u044a\u0435\u043a\u0442 <code>manager = OverloadManager()<\/code>, \u0434\u0430\u043b\u0435\u0435 \u0432 \u043d\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u044f-\u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 <code>overload<\/code> \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438.<\/p>\n<\/blockquote>\n<pre><code class=\"python\">&gt;&gt;&gt; from my_library import overloading  &gt;&gt;&gt; overloading.manager.methods {('__main__',   'Model',   'fit'): &lt;my_library.overloading.OverloadFunction at 0x12fa82ec0&gt;,  ('__main__',   'Model',   'predict'): &lt;my_library.overloading.OverloadFunction at 0x14f8b0b80&gt;}  # \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u044f \u0437\u0434\u0435\u0441\u044c `__main__` \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043d\u0430\u0448\u0438 # \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u0432\u044b\u0448\u0435 \u0432 jupyter notebook.<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438. \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438, \u0430 \u043d\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438, \u0442\u043e \u043a\u043b\u044e\u0447\u043e\u043c \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u0437 \u043d\u0438\u0445 \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u0440\u0442\u0435\u0436, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u044f, \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0441\u0430\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<pre><code class=\"python\">&gt;&gt;&gt; overloading.manager.methods[('__main__', 'Model', 'fit')].overloads {(inspect._empty,   __main__.Dataset,   typing.Union[pandas.core.series.Series, pandas.core.indexes.base.Index, numpy.ndarray, list, tuple, NoneType]): &lt;function __main__.Model.fit(self, dataset: __main__.Dataset, features: Union[pandas.core.series.Series, pandas.core.indexes.base.Index, numpy.ndarray, list, tuple, NoneType] = None, **kwargs)&gt;,  (inspect._empty,   typing.Union[pandas.core.frame.DataFrame, numpy.ndarray],   typing.Union[pandas.core.series.Series, pandas.core.indexes.base.Index, numpy.ndarray, list, tuple]): &lt;function __main__.Model.fit(self, X: Union[pandas.core.frame.DataFrame, numpy.ndarray], y: Union[pandas.core.series.Series, pandas.core.indexes.base.Index, numpy.ndarray, list, tuple], **kwargs)&gt;}  &gt;&gt;&gt; overloading.manager.methods[('__main__', 'Model', 'predict')].overloads {(inspect._empty,   __main__.Dataset): &lt;function __main__.Model.predict(self, dataset: __main__.Dataset, **kwargs)&gt;,  (inspect._empty,   typing.Union[pandas.core.frame.DataFrame, numpy.ndarray]): &lt;function __main__.Model.predict(self, X: Union[pandas.core.frame.DataFrame, numpy.ndarray], **kwargs)&gt;}<\/code><\/pre>\n<h3>\u0422\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 overload<\/h3>\n<p><strong>1. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 <\/strong><code><strong>Union<\/strong><\/code><strong> \u0438 <\/strong><code><strong>Optional<\/strong><\/code><\/p>\n<ul>\n<li>\n<p><code>Union[int, str]<\/code> \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u0434\u0442\u0438\u043f\u044b <code>(int, str)<\/code>, \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p><code>Optional[float]<\/code> (\u0442\u043e \u0435\u0441\u0442\u044c <code>Union[float, None]<\/code>) \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b <code>None<\/code> \u043d\u0435 \u043c\u0435\u0448\u0430\u043b, \u0435\u0441\u043b\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u2014 <code>float<\/code>. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e\u0439.<\/p>\n<\/li>\n<\/ul>\n<p><strong>2. \u041b\u0435\u043d\u0438\u0432\u044b\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u044b<\/strong><\/p>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0438\u043f \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043b\u0435\u043d\u0438\u0432\u043e (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 <code>LazyImport<\/code>), \u043c\u044b \u043d\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0435\u0433\u043e \u0441\u0440\u0430\u0437\u0443, \u0430 \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0432\u044b\u0437\u043e\u0432\u0430. \u042d\u0442\u043e \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>from future import annotations<\/code> \u043b\u043e\u043c\u0430\u0435\u0442 \u043d\u0430\u0448\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e.<\/p>\n<blockquote>\n<p><code><strong>LazyImport<\/strong><\/code><strong>: <\/strong>\u041d\u0430\u0448 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432. \u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0430\u043c\u0438 \u0438 \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0438\u043c\u043f\u043e\u0440\u0442 \u0442\u044f\u0436\u0435\u043b\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a. \u041f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 <code>resolve()<\/code> \u043e\u043d \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u0438\u043f.<\/p>\n<\/blockquote>\n<p><strong>3. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/strong><\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f <code>bind_partial<\/code> \u0438 <code>apply_defaults<\/code> \u043c\u044b \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0441 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u044b \u0432 \u0432\u044b\u0437\u043e\u0432\u0435.<\/p>\n<p><strong>4. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043e\u043a<\/strong><\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0439 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e, \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u0442\u0438\u043f\u043e\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0447\u0442\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043e\u0442\u043b\u0430\u0434\u043a\u0443.<\/p>\n<p><strong>5. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 <\/strong><code><strong>*args<\/strong><\/code><strong> \u0438 <\/strong><code><strong>**kwargs<\/strong><\/code><\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>inspect.Parameter.VAR_POSITIONAL<\/code> \u0438 <code>inspect.Parameter.VAR_KEYWORD<\/code>, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044f \u0441 \u043d\u0438\u043c \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b.<\/p>\n<p><strong>6. \u041f\u0440\u043e\u043f\u0443\u0441\u043a <\/strong><code><strong>self<\/strong><\/code><strong> \u0432 \u043c\u0435\u0442\u043e\u0434\u0430\u0445<\/strong><\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u2014 <code>self<\/code>, \u043c\u044b \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0435\u0433\u043e \u043f\u0440\u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0442\u0438\u043f\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>self<\/code>, \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441 <code>inspect.Parameter.empty<\/code>.<\/p>\n<p><strong>7. \u0420\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438<\/strong><\/p>\n<p>\u041f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0445 \u0438\u043c\u0435\u043d\u0430 \u0432 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0435, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0440\u0442\u0435\u0436, \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0439 \u0438\u043c\u044f \u043c\u0435\u0442\u043e\u0434\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u043d\u0430 \u043c\u043e\u0434\u0443\u043b\u044f \u0438 \u043a\u043b\u0430\u0441\u0441\u0430. \u042d\u0442\u043e \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d\u043e \u0442\u0435\u043c, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434\u044b \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 (\u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f) \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 <code>Model<\/code> \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0438 <code>GridSearch<\/code> \u0434\u043b\u044f \u043f\u043e\u0434\u0431\u043e\u0440\u0430 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>fit()<\/code>, \u043d\u043e \u0435\u0433\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c.<\/p>\n<h3>\u0427\u0442\u043e \u0435\u0449\u0451 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e \u0442\u0435\u043c\u0435<\/h3>\n<ol>\n<li>\n<p><a href=\"https:\/\/docs.python.org\/3\/library\/typing.html\">typing \u2014 Support for type hints \u2014 Python documentation<\/a> \u2014 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <code>typing<\/code> \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0442\u0438\u043f\u043e\u0432 (<code>get_type_hints<\/code>, <code>get_origin<\/code>, <code>get_args<\/code>).<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.python.org\/3\/library\/inspect.html\">inspect \u2014 Inspect live objects \u2014 Python documentation<\/a> \u2014 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u044f <code>inspect<\/code> \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.python.org\/dev\/peps\/pep-0484\/\">PEP 484 \u2014 Type Hints<\/a> \u2014 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0442\u0438\u043f\u043e\u0432 \u0432 Python.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.python.org\/dev\/peps\/pep-0563\/\">PEP 563 \u2014 postponed evaluation of type annotations<\/a> \u2014 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0442\u0438\u043f\u043e\u0432.<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><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\/ru\/articles\/898530\/\"> https:\/\/habr.com\/ru\/articles\/898530\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0447\u0430\u0441\u0442\u043e \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0441 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0434\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u0427\u0442\u043e\u0431\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 (overload). \u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0438\u043c\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0439 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0435 \u043e\u0434\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0434 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u0434 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u044b\u043c \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c.\u00a0<\/p>\n<p>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u0432 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0412 \u043a\u043e\u043d\u0446\u0435 \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0438 \u0437\u0430\u0447\u0435\u043c \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u043d\u0430 Python \u0441\u0432\u043e\u0438\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c.<\/p>\n<figure class=\"full-width\"><\/figure>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/h3>\n<p>\u041f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 (function overloading) \u2014 \u044d\u0442\u043e \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c, \u043d\u043e \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430\u043c\u0438: \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c, \u0442\u0438\u043f\u0430\u043c\u0438 \u0438\u043b\u0438 \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432.\u00a0<\/p>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u042d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0441\u0442\u0440\u043e\u0433\u043e \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445, \u0447\u0442\u043e\u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u0433\u0438\u0431\u043a\u0438\u0439 \u0438 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u043a\u043e\u0434 \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0449\u0435.<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 C++ \u0438 Typescript<\/h4>\n<p>C++ \u2014 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u044f\u0437\u044b\u043a\u0430 \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u00ab\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438\u00bb. \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c sum, \u043d\u043e \u0441 \u0440\u0430\u0437\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432\u00a0\u2014 <code>int<\/code> \u0438 <code>double<\/code>:<\/p>\n<pre><code class=\"cpp\">#include &lt;iostream&gt; #include &lt;string&gt;  int sum(int a, int b) {     return a + b; }  double sum(double a, double b) {     return a + b; }  int main() {     std::cout &lt;&lt; sum(2, 3) &lt;&lt; std::endl;     \/\/ \u0412\u044b\u0437\u043e\u0432\u0435\u0442 sum(int, int)     std::cout &lt;&lt; sum(2.5, 3.1) &lt;&lt; std::endl; \/\/ \u0412\u044b\u0437\u043e\u0432\u0435\u0442 sum(double, double)     return 0; }<\/code><\/pre>\n<p>\u0412 TypeScript \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0442\u0438\u043f\u043e\u0432. \u0417\u0434\u0435\u0441\u044c \u0434\u0432\u0435 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u044b \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 greet, \u0430 \u0441\u0430\u043c\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0434\u043d\u0430. \u041e\u043d\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u043a\u0430\u043a\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u0440\u0438\u0448\u043b\u0438:<\/p>\n<pre><code class=\"typescript\">function greet(name: string): string; function greet(name: string, age: number): string; function greet(name: string, age?: number): string {   if (age !== undefined) {     return `Hello, ${name}! You are ${age} years old.`;   } else {     return `Hello, ${name}!`;   } }  console.log(greet(\"Alice\"));       \/\/ \"Hello, Alice!\" console.log(greet(\"Bob\", 30));     \/\/ \"Hello, Bob! You are 30 years old.\" <\/code><\/pre>\n<p><strong>\u041f\u043e\u0447\u0435\u043c\u0443 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 \u0447\u0438\u0441\u0442\u043e\u043c \u0432\u0438\u0434\u0435 \u043d\u0435\u0442 \u0432 Python \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445?<\/strong><\/p>\n<p>Python \u2014 \u044f\u0437\u044b\u043a \u0441 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0435\u0439. \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043b\u044e\u0431\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u043e\u0447\u0442\u0438 \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u00ab\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f\u00bb \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u0438\u0434\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435.\u00a0<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 Python \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c, \u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u00ab\u0437\u0430\u0442\u0440\u0435\u0442\u00bb \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0443\u044e:<\/p>\n<pre><code class=\"python\">def hello(name: str):     print(f\"Hello {name}\")  def hello(age: int):     print(f\"Your age is {age}\")  hello(\"Alice\")  # \"Your age is Alice\" \u2013 \u043e\u0448\u0438\u0431\u043a\u0430: \u0432\u044b\u0437\u043e\u0432\u0435\u0442\u0441\u044f \u0432\u0442\u043e\u0440\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f, \u043d\u043e \u043e\u043d\u0430 \u0436\u0434\u0451\u0442 int.<\/code><\/pre>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 Python \u043d\u0435\u0442. \u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 (:<\/p>\n<h4>\u041a\u0430\u043a \u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u0432 Python?<\/h4>\n<p>\u041d\u0438\u0436\u0435 \u043e\u043f\u0438\u0448\u0443 \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c Python-\u043a\u043e\u0434\u0435. \u041f\u0435\u0440\u0432\u044b\u0439 \u2014 \u0441\u0430\u043c\u044b\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u2014 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p><strong>1. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0442\u0438\u043f\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/strong><\/p>\n<pre><code class=\"python\">def hello(name_or_age):     if isinstance(name_or_age, str):         print(f\"Hello {name_or_age}\")     elif isinstance(name_or_age, int):         print(f\"Your age is {name_or_age}\")     else:         raise TypeError(\"Expected str or int\")<\/code><\/pre>\n<p>\u041c\u0438\u043d\u0443\u0441 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u2014 \u0435\u0434\u0438\u043d\u0430\u044f \u043c\u043e\u043d\u043e\u043b\u0438\u0442\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0437\u0434\u0443\u0442\u044c\u0441\u044f \u0438 \u0441\u0442\u0430\u0442\u044c \u043d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0439. \u0410 \u0435\u0449\u0435 \u043e\u043d\u0430 \u043d\u0435 \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0435\u0440\u0441\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430\u043c\u0438.<\/p>\n<p><strong>2. \u0423\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438:<\/strong><\/p>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<pre><code class=\"python\">def hello_str(name):     print(f\"Hello {name}\")  def hello_int(age):     print(f\"Your age is {age}\")<\/code><\/pre>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442 \u0438 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u0435\u043d, \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0433\u043e \u0443\u0434\u043e\u0431\u043d\u044b\u043c \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u0433\u0434\u0435 \u0432\u0430\u0436\u043d\u0430 \u044f\u0432\u043d\u043e\u0441\u0442\u044c. \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 \u043a\u043e\u0434\u0435 \u0438 \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435\u0442 \u0435\u0434\u0438\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043f\u043e\u0445\u043e\u0436\u0438\u043c\u0438 \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0438 \u043c\u043e\u0436\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c API \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u043c.<\/p>\n<p><strong>3. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 <\/strong><code><strong>functools.singledispatch<\/strong><\/code><strong> (\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0441 Python 3.4):<\/strong><\/p>\n<pre><code class=\"python\">from functools import singledispatch  @singledispatch def hello(arg):     raise TypeError(\"Unsupported type\")  @hello.register def _(arg: str):     print(f\"Hello {arg}\")  @hello.register def _(arg: int):     print(f\"Your age is {arg}\") <\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u041d\u043e <code>singledispatch<\/code> \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u043d\u0430 \u0442\u0438\u043f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430, \u0430 \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, <code>Union<\/code>, <code>Optional<\/code> \u0438 \u0442. \u0434.) \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e.<\/p>\n<p><strong>4. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <\/strong><code><strong>multipledispatch<\/strong><\/code><strong>:<\/strong><\/p>\n<pre><code class=\"python\">from multipledispatch import dispatch  @dispatch(str) def hello(arg):     print(f\"Hello {arg}\")  @dispatch(int) def hello(arg):     print(f\"Your age is {arg}\")<\/code><\/pre>\n<p>\u042d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440, \u043d\u043e \u043e\u043d\u0430 \u043d\u0435 \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 Python \u2014 \u0442\u0430\u043a \u0447\u0442\u043e \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0435\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043e\u043d\u0430 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u043e\u0432.<\/p>\n<p><strong>5. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a<\/strong><\/p>\n<p>\u041d\u0435\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438\u043b\u0438 \u0441\u0430\u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u044b\u0442\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u044b \u0447\u0435\u0440\u0435\u0437 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0434\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u0435\u0441\u0442\u0430\u0445. \u0418\u043c\u0435\u043d\u043d\u043e \u0432 \u044d\u0442\u0443 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e \u0438 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u0432 \u0432\u043e\u043f\u0440\u043e\u0441\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f.<\/p>\n<h3>\u041a\u0430\u043a \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 Python<\/h3>\n<p>\u041c\u044b \u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u043f\u0440\u0438\u0448\u043b\u0438 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043d\u0435\u0442 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043d\u0430\u043c \u043f\u043e\u0434\u043e\u0448\u0435\u043b. \u041e\u043d\u0438:<\/p>\n<ul>\n<li>\n<p>\u0438\u043c\u0435\u044e\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u044e\u0442\u0441\u044f<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u0443\u043c\u0435\u044e\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 generic&#8217;\u0430\u043c\u0438 \u043f\u043e \u0442\u0438\u043f\u0443 Union, Optional, \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0441 args, **kwargs.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430\u0448\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0435 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043f\u043e\u0434 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043d\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043d\u0430\u0448\u0438 \u0442\u0435\u0445\u043d\u0438\u043a\u0438: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, LazyImport. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u0438 \u043a\u043e\u043b\u043b\u0435\u0433\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u044b (:<\/p>\n<p>\u041d\u0430\u0448\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u2014 <code>OverloadManager<\/code>, <code>OverloadFunction<\/code>, \u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 <code>@overload<\/code>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c, \u043a\u0430\u043a \u043e\u043d\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u0438 \u0440\u0435\u0448\u0430\u044e\u0442 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438.<\/p>\n<blockquote>\n<p><strong>\u0412\u0430\u0436\u043d\u043e:<\/strong> \u041d\u0430\u0448\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f <code>overload<\/code> \u2014 \u044d\u0442\u043e \u043d\u0435 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e <code>@overload<\/code> \u0438\u0437 <code>typing<\/code>. \u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0438\u0437 <code>typing<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 runtime-\u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043d\u0430\u0448\u0430 \u0432\u0435\u0440\u0441\u0438\u044f \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0430 \u043d\u0430 <strong>\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0432\u044b\u0437\u043e\u0432\u043e\u0432<\/strong> \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0442\u0438\u043f\u043e\u0432 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432.  <\/p>\n<\/blockquote>\n<p><strong>1. \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 (<\/strong><code><strong>OverloadManager.register<\/strong><\/code><strong>)<\/strong><\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 <code>@overload<\/code> \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043e\u043d\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 <code>OverloadManager<\/code>. \u0417\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0430\u0436\u043d\u044b\u0439 \u0448\u0430\u0433 \u2014 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<details class=\"spoiler\">\n<summary>\u041e\u0442\u043b\u0438\u0447\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0442 \u043c\u0435\u0442\u043e\u0434\u0430<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>__qualname__<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0435 \u0438\u043c\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<ul>\n<li>\n<p>\u0414\u043b\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438: <code>__qualname__ = \"process\"<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u043a\u043b\u0430\u0441\u0441\u0430: <code>__qualname__ = \"MyClass.process\"<\/code>.<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/details>\n<p>\u0415\u0441\u043b\u0438 \u0432 <code><strong>__qualname__<\/strong><\/code> \u0435\u0441\u0442\u044c \u0442\u043e\u0447\u043a\u0430 (<code>.<\/code>), \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u2014 \u043c\u0435\u0442\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430. \u0422\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0438\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435 <code>self.methods<\/code> \u0441 \u043a\u043b\u044e\u0447\u043e\u043c <code>(module, class_name, method_name)<\/code>. \u0414\u043b\u044f \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u043c\u044f \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435 <code>self.functions<\/code>.<\/p>\n<p><strong>\u0417\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e? <\/strong>\u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f (\u0447\u0435\u0440\u0435\u0437 <code><strong>__mro__<\/strong><\/code>, \u043e \u0447\u0435\u043c \u043d\u0438\u0436\u0435).<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432<\/figcaption><\/div>\n<\/figure>\n<p><strong>2. \u0410\u043d\u0430\u043b\u0438\u0437 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b (<\/strong><code><strong>OverloadFunction.register<\/strong><\/code><strong>)<\/strong><\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043c\u044b \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443. \u0410\u043d\u0430\u043b\u0438\u0437 \u0440\u0430\u0437\u0431\u0438\u0442 \u043d\u0430 \u044d\u0442\u0430\u043f\u044b:<\/p>\n<ul>\n<li>\n<p><strong>\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <code>inspect.signature<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 <code>Signature<\/code>. \u041c\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043cc\u044f \u043f\u043e \u0432\u0441\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c \u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0438\u0445 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u043e\u0432, \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f <code>*args<\/code> \u0438 <code>**kwargs<\/code> (\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432), \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0438 \u043d\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 \u0441\u0442\u0440\u043e\u0433\u043e\u0439 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0435. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u2014 \u043a\u043e\u0440\u0442\u0435\u0436 \u0442\u0438\u043f\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: <code>(int, str)<\/code>.<\/p>\n<ul>\n<li>\n<p><strong>\u041d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 (<\/strong><code><strong>_normalize_annotation<\/strong><\/code><strong>)<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>Union[int, str]<\/code>, <code>List[str]<\/code>, <code>Optional[float]<\/code>), \u0438 \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0443\u0434\u043e\u0431\u043d\u043e\u043c\u0443 \u0432\u0438\u0434\u0443:<\/p>\n<ul>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 <code>Union<\/code>: \u0415\u0441\u043b\u0438 \u0442\u0438\u043f \u2014 <code>Union<\/code>, \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>get_origin<\/code> (\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>Union<\/code>) \u0438 <code>get_args<\/code> (\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>(int, str)<\/code>), \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u043f\u043e\u0434\u0442\u0438\u043f\u044b \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 generic-\u0442\u0438\u043f\u043e\u0432: \u0414\u043b\u044f <code>List[str]<\/code> <code>get_origin<\/code> \u0432\u0435\u0440\u043d\u0435\u0442 <code>list<\/code>, \u0430 <code>get_args<\/code> \u2014 <code>(str,)<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u041b\u0435\u043d\u0438\u0432\u044b\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u044b: \u0415\u0441\u043b\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u2014 \u043e\u0431\u044a\u0435\u043a\u0442 <code>LazyImport<\/code>, \u043c\u044b \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0435\u0451 \u0432 <code>LazyTypeWrapper<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043b\u043e\u0436\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0432\u044b\u0437\u043e\u0432\u0430.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><strong>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435 <code>self.overloads<\/code> \u0441 \u043a\u043b\u044e\u0447\u043e\u043c \u2014 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u043c \u0442\u0438\u043f\u043e\u0432, \u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u2014 \u0441\u0430\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439.<\/p>\n<pre><code class=\"python\">class OverloadFunction:     def __init__(self, name: str):         self.name = name         self.overloads = {}      def register(self, func) -&gt; None:         # \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432         # \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439         # \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u0440\u0442\u0435\u0436\u0430 param_types                  self.overloads[param_types] = func <\/code><\/pre>\n<p><strong>3. \u0412\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (<\/strong><code><strong>OverloadFunction.__call__<\/strong><\/code><strong>)<\/strong><\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c, \u043a\u0430\u043a\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430, \u043f\u043e \u0442\u0430\u043a\u043e\u043c\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443:<\/p>\n<ul>\n<li>\n<p><strong>\u0421\u0431\u043e\u0440 \u0442\u0438\u043f\u043e\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 <code>(args)<\/code> \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u0440\u0442\u0435\u0436 \u0438\u0445 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>tuple(type(arg) for arg in args)<\/code>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b\u0437\u043e\u0432 <code>process(42, \"hello\")<\/code> \u0434\u0430\u0435\u0442 <code>(int, str)<\/code>.<\/p>\n<ul>\n<li>\n<p><strong>\u0421\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 (<\/strong><code><strong>_match_types<\/strong><\/code><strong>)<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u043e \u0441\u0435\u0440\u0434\u0446\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u0433\u0434\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0442\u0438\u043f\u044b \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0441 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432:<\/p>\n<ul>\n<li>\n<p><strong>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0434\u043b\u0438\u043d\u044b: <\/strong>\u0415\u0441\u043b\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u044d\u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u041c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432:<\/strong> \u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u2014 <code>self<\/code> (\u043f\u0443\u0441\u0442\u0430\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f), \u043e\u043d \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b.<\/p>\n<\/li>\n<li>\n<p><strong>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 <\/strong><code><strong>Union<\/strong><\/code><strong>:<\/strong> \u0415\u0441\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f <code>Union[int, str]<\/code>, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>get_args<\/code> \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f <code>(int, str)<\/code> \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0442\u0438\u043f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u043e\u043c \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445 \u0447\u0435\u0440\u0435\u0437 <code>issubclass<\/code>. \u0415\u0441\u043b\u0438 \u0432 <code>Union<\/code> \u0435\u0441\u0442\u044c <code>None<\/code>, \u043e\u043d \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u0435\u0441\u043b\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043d\u0435 <code>None<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>\u041b\u0435\u043d\u0438\u0432\u044b\u0435 \u0442\u0438\u043f\u044b:<\/strong> \u0414\u043b\u044f <code>LazyTypeWrapper<\/code> \u043c\u044b \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0442\u0438\u043f \u0447\u0435\u0440\u0435\u0437 <code>resolve()<\/code>. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u0443\u0434\u0430\u0435\u0442\u0441\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0437-\u0437\u0430 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0430), \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0438\u043c\u0435\u043d\u0430 \u0442\u0438\u043f\u043e\u0432 \u043a\u0430\u043a \u0437\u0430\u043f\u0430\u0441\u043d\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442.<\/p>\n<\/li>\n<li>\n<p><strong>Generic-\u0442\u0438\u043f\u044b:<\/strong> \u0415\u0441\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u2014 <code>list<\/code>, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u043e\u043c <code>list<\/code> (\u0447\u0435\u0440\u0435\u0437 <code>issubclass<\/code>).<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><strong>\u0412\u044b<\/strong><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-455602","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/455602","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=455602"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/455602\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=455602"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=455602"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=455602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}