{"id":336740,"date":"2022-08-08T15:01:02","date_gmt":"2022-08-08T15:01:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=336740"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=336740","title":{"rendered":"<span>\u0423\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0435 Python-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043f\u043e\u0440\u0430 \u043f\u043e\u043f\u0440\u043e\u0449\u0430\u0442\u044c\u0441\u044f<\/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>\u0412 Python, \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u0440\u0435\u043b\u0438\u0437\u043e\u043c, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u043d\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u0438 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447. \u0412\u0441\u0435 \u043c\u044b \u043f\u0440\u0438\u0432\u044b\u043a\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0442\u0430\u0440\u044b\u043c\u0438 \u0434\u043e\u0431\u0440\u044b\u043c\u0438 Python-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438, \u043f\u0440\u0438\u0432\u044b\u043a\u043b\u0438 \u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c \u0440\u0430\u0431\u043e\u0442\u044b. \u041d\u043e \u043f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f, \u0432\u0440\u0435\u043c\u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u043e\u0432\u044b\u043c\u0438 \u0438 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u043d\u044b\u043c\u0438 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438 \u0438 \u0438\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/568\/63d\/30c\/56863d30cbff6aa55661935486bf276c.png\" width=\"780\" height=\"440\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/568\/63d\/30c\/56863d30cbff6aa55661935486bf276c.png\"\/><figcaption><\/figcaption><\/figure>\n<h3>Pathlib<\/h3>\n<p>\u041c\u043e\u0434\u0443\u043b\u044c\u00a0<code>pathlib<\/code>\u00a0\u2014 \u044d\u0442\u043e, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e, \u043e\u0434\u043d\u043e \u0438\u0437 \u043a\u0440\u0443\u043f\u043d\u0435\u0439\u0448\u0438\u0445 \u043d\u0435\u0434\u0430\u0432\u043d\u0438\u0445 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Python. \u042d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u0441\u0442\u0430\u043b \u0447\u0430\u0441\u0442\u044c\u044e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Python 3.4. \u041f\u0440\u0430\u0432\u0434\u0430, \u043c\u043d\u043e\u0433\u0438\u0435 \u0432\u0441\u0451 \u0435\u0449\u0451 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u043c\u00a0<code>os<\/code>\u00a0\u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439.<\/p>\n<p>\u041d\u043e \u043c\u043e\u0434\u0443\u043b\u044c\u00a0<code>pathlib<\/code>, \u0432\u0441\u0451 \u0436\u0435, \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u043b\u0443\u0447\u0448\u0435 \u0441\u0442\u0430\u0440\u043e\u0433\u043e\u00a0<code>os.path<\/code>. \u0422\u0430\u043a, \u043c\u043e\u0434\u0443\u043b\u044c <code>os<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0443\u0442\u0438 \u0432 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0432 \u0432\u0438\u0434\u0435 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a, \u0430 \u0432\u00a0<code>pathlib<\/code>\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u0442\u0438\u043b\u044c. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442\u0441\u044f \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0435\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"python\">from pathlib import Path import os.path  # \u0421\u0442\u0430\u0440\u044b\u0439 \u043a\u043e\u0434 \u0441 \u043f\u043b\u043e\u0445\u043e\u0439 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e two_dirs_up = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # \u041d\u043e\u0432\u044b\u0439, \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 two_dirs_up = Path(__file__).resolve().parent.parent<\/code><\/pre>\n<p>\u0422\u043e\u0442 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u043f\u0443\u0442\u0438 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0430 \u043d\u0435 \u043a\u0430\u043a \u0441\u0442\u0440\u043e\u043a\u0438, \u0434\u0435\u043b\u0430\u0435\u0442, \u043a\u0440\u043e\u043c\u0435 \u043f\u0440\u043e\u0447\u0435\u0433\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0435\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c \u0438\u043b\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u043d\u0438\u043c\u0438:<\/p>\n<pre><code class=\"python\">readme = Path(\"README.md\").resolve()  print(f\"Absolute path: {readme.absolute()}\") # Absolute path: \/home\/martin\/some\/path\/README.md print(f\"File name: {readme.name}\") # File name: README.md print(f\"Path root: {readme.root}\") # Path root: \/ print(f\"Parent directory: {readme.parent}\") # Parent directory: \/home\/martin\/some\/path print(f\"File extension: {readme.suffix}\") # File extension: .md print(f\"Is it absolute: {readme.is_absolute()}\") # Is it absolute: True<\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430 \u0438\u0437 \u043c\u043e\u0438\u0445 \u043b\u044e\u0431\u0438\u043c\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439\u00a0<code>pathlib<\/code>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u0445\u043e\u0447\u0443 \u043e\u0441\u043e\u0431\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u044d\u0442\u043e \u2014 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u00a0<code>\/<\/code>\u00a0(\u043e\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u00ab\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u00bb) \u0434\u043b\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043f\u0443\u0442\u0435\u0439:<\/p>\n<pre><code class=\"python\"># \u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b: etc = Path('\/etc')  joined = etc \/ \"cron.d\" \/ \"anacron\" print(f\"Exists? - {joined.exists()}\") # Exists? - True<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0432\u0435\u0441\u044c\u043c\u0430 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043f\u0443\u0442\u044f\u043c\u0438. \u042d\u0442\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u2014 \u043d\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0438\u0448\u0435\u043d\u043a\u0430 \u043d\u0430 \u00ab\u0442\u043e\u0440\u0442\u0435\u00bb <code>pathlib<\/code>.<\/p>\n<p>\u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u044d\u0442\u043e \u2014 \u0432\u0430\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u043e\u0434\u0443\u043b\u044c\u00a0<code>pathlib<\/code>\u00a0\u2014 \u044d\u0442\u043e \u0437\u0430\u043c\u0435\u043d\u0430 \u043b\u0438\u0448\u044c \u0434\u043b\u044f\u00a0<code>os.path<\/code>, \u0430 \u043d\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f\u00a0<code>os<\/code>. \u0412\u00a0<code>pathlib<\/code>, \u043f\u0440\u0430\u0432\u0434\u0430, \u0432\u043a\u043b\u044e\u0447\u0451\u043d \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f\u00a0<code>glob<\/code>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u0440\u0438\u0432\u044b\u043a\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f\u00a0<code>os.path<\/code>\u00a0\u0432 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0441\u00a0<code>glob.glob<\/code>, \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e, \u043f\u0435\u0440\u0435\u0439\u0434\u044f \u043d\u0430\u00a0<code>pathlib<\/code>, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0431\u044b\u0442\u044c \u043e\u0431 \u0438\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0438.<\/p>\n<p>\u0412 \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u043f\u0440\u0438\u0451\u043c\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0443\u0442\u044f\u043c\u0438 \u0438 \u0441 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u043f\u0443\u0442\u044c. \u041d\u043e \u0432\u00a0<code>pathlib<\/code>\u00a0\u0438\u043c\u0435\u044e\u0442\u0441\u044f \u0435\u0449\u0451 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b, \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0435 \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441\u00a0<code>os.path<\/code>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"python\">print(f\"Working directory: {Path.cwd()}\")  # \u0442\u043e \u0436\u0435, \u0447\u0442\u043e os.getcwd() # Working directory: \/home\/martin\/some\/path Path.mkdir(Path.cwd() \/ \"new_dir\", exist_ok=True)  # \u0442\u043e \u0436\u0435, \u0447\u0442\u043e os.makedirs() print(Path(\"README.md\").resolve())  # \u0442\u043e \u0436\u0435, \u0447\u0442\u043e os.path.abspath() # \/home\/martin\/some\/path\/README.md print(Path.home())  # \u0442\u043e \u0436\u0435, \u0447\u0442\u043e os.path.expanduser() # \/home\/martin<\/code><\/pre>\n<p>\u041f\u043e\u043b\u043d\u044b\u0435 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439\u00a0<code>os.path<\/code>\u00a0\u0438 \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438\u0437\u00a0<code>pathlib<\/code>\u00a0\u0438\u043c\u0435\u044e\u0442\u0441\u044f \u0432\u00a0<a href=\"https:\/\/docs.python.org\/3\/library\/pathlib.html#correspondence-to-tools-in-the-os-module\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<p>\u0411\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430\u00a0<code>pathlib<\/code>, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432\u00a0<a href=\"https:\/\/treyhunner.com\/2018\/12\/why-you-should-be-using-pathlib\/\">\u044d\u0442\u043e\u0439<\/a>\u00a0\u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<h3>Secrets<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440 \u043e \u043c\u043e\u0434\u0443\u043b\u0435\u00a0<code>os<\/code>, \u0442\u043e \u0435\u0449\u0451 \u043e\u0434\u043d\u0430 \u0435\u0433\u043e \u0447\u0430\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u043f\u043e\u043a\u043e\u0439 \u2014 \u044d\u0442\u043e\u00a0<code>os.urandom<\/code>. \u0412\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0451 \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c\u00a0<code>secrets<\/code>, \u0438\u043c\u0435\u044e\u0449\u0438\u0439\u0441\u044f \u0432 \u043d\u0430\u0448\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u0440\u044f\u0436\u0435\u043d\u0438\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Python 3.6:<\/p>\n<pre><code class=\"python\"># \u0421\u0442\u0430\u0440\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434: import os  length = 64  value = os.urandom(length) print(f\"Bytes: {value}\") # Bytes: b'\\xfa\\xf3...\\xf2\\x1b\\xf5\\xb6' print(f\"Hex: {value.hex()}\") # Hex: faf3cc656370e31a938e7...33d9b023c3c24f1bf5  # \u041d\u043e\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434: import secrets  value = secrets.token_bytes(length) print(f\"Bytes: {value}\") # Bytes: b'U\\xe9n\\x87...\\x85>\\x04j:\\xb0' value = secrets.token_hex(length) print(f\"Hex: {value}\") # Hex: fb5dd85e7d73f7a08b8e3...4fd9f95beb08d77391<\/code><\/pre>\n<p>\u0422\u0443\u0442, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u043c\u043e\u0434\u0443\u043b\u044c\u00a0<code>os.urandom<\/code>. \u041d\u043e <a href=\"https:\/\/peps.python.org\/pep-0506\/#rationale\">\u043f\u0440\u0438\u0447\u0438\u043d\u0430<\/a> \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u044f\u00a0<code>secrets<\/code>\u00a0\u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043c\u043e\u0434\u0443\u043b\u044c <code>random<\/code>\u00a0\u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u0440\u043e\u043b\u0435\u0439 \u0438 \u043f\u0440\u043e\u0447\u0435\u0433\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e. \u0418 \u044d\u0442\u043e \u2014 \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043c\u043e\u0434\u0443\u043b\u044c\u00a0<code>random<\/code>\u00a0\u043d\u0435 \u0432\u044b\u0434\u0430\u0451\u0442 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u0442\u043e\u043a\u0435\u043d\u044b.<\/p>\n<p>\u041c\u043e\u0434\u0443\u043b\u044c\u00a0<code>random<\/code>, \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439, \u043d\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0446\u0435\u043b\u0435\u0439, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c\u044e. \u041d\u0430\u0434\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043b\u0438\u0431\u043e\u00a0<code>secrets<\/code>, \u043b\u0438\u0431\u043e\u00a0<code>os.urandom<\/code>. \u041d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0435\u043d\u0438\u0435, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e, \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u0434\u0430\u0442\u044c\u00a0<code>secrets<\/code>, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0442\u043e, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u043d\u043e\u0432\u0435\u0435, \u0438 \u0442\u043e, \u0447\u0442\u043e \u043e\u043d \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0442\u0438\u043b\u0438\u0442\u044b\/\u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0448\u0435\u0441\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u0435\u0440\u0438\u0447\u043d\u044b\u043c\u0438 \u0442\u043e\u043a\u0435\u043d\u0430\u043c\u0438, \u0430 \u0442\u0430\u043a \u0436\u0435 \u2014 \u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 URL-\u0430\u0434\u0440\u0435\u0441\u0430\u043c\u0438, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u043c\u0438 \u043c\u0430\u0440\u043a\u0435\u0440 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438.<\/p>\n<h3>Zoneinfo<\/h3>\n<p>\u0414\u043e Python 3.9 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043c\u043e\u0434\u0443\u043b\u044f \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u0430\u0442\u044b \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0447\u0430\u0441\u043e\u0432\u044b\u043c\u0438 \u043f\u043e\u044f\u0441\u0430\u043c\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043c\u043e\u0434\u0443\u043b\u0435\u043c\u00a0<code>pytz<\/code>. \u041d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u044c <code>zoneinfo<\/code>. \u0410 \u0437\u043d\u0430\u0447\u0438\u0442 \u2014 \u043f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0435\u0433\u043e!<\/p>\n<pre><code class=\"python\">from datetime import datetime import pytz  # pip install pytz  dt = datetime(2022, 6, 4) nyc = pytz.timezone(\"America\/New_York\")  localized = nyc.localize(dt) print(f\"Datetime: {localized}, Timezone: {localized.tzname()}, TZ Info: {localized.tzinfo}\")  # \u041f\u043e-\u043d\u043e\u0432\u043e\u043c\u0443: from zoneinfo import ZoneInfo  nyc = ZoneInfo(\"America\/New_York\") localized = datetime(2022, 6, 4, tzinfo=nyc) print(f\"Datetime: {localized}, Timezone: {localized.tzname()}, TZ Info: {localized.tzinfo}\") # Datetime: 2022-06-04 00:00:00-04:00, Timezone: EDT, TZ Info: America\/New_York<\/code><\/pre>\n<p>\u041c\u043e\u0434\u0443\u043b\u044c\u00a0<code>datetime<\/code>\u00a0\u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0435 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 \u0447\u0430\u0441\u043e\u0432\u044b\u043c\u0438 \u043f\u043e\u044f\u0441\u0430\u043c\u0438 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u043c\u0443 \u0431\u0430\u0437\u043e\u0432\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443\u00a0<code>datetime.tzinfo<\/code>. \u042d\u0442\u043e\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043d\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0414\u043e \u0432\u044b\u0445\u043e\u0434\u0430 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0442\u0430\u043a\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u043f\u043e \u0432\u0441\u0435\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438, \u0431\u0440\u0430\u043b\u0438 \u0438\u0437 <code>pytz<\/code>. \u0410 \u0442\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0435\u0441\u0442\u044c\u00a0<code>zoneinfo<\/code>, \u044d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u043e\u00a0<code>pytz<\/code>.<\/p>\n<p>\u0423 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u00a0<code>zoneinfo<\/code>, \u043f\u0440\u0430\u0432\u0434\u0430, \u0435\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u043d\u044e\u0430\u043d\u0441: \u043c\u043e\u0434\u0443\u043b\u044c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442, \u0447\u0442\u043e \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0438\u043c\u0435\u044e\u0442\u0441\u044f \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e \u0447\u0430\u0441\u043e\u0432\u044b\u0445 \u043f\u043e\u044f\u0441\u0430\u0445. \u0412 UNIX-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u044d\u0442\u043e \u0442\u0430\u043a. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0432 \u0432\u0430\u0448\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0442\u0430\u043a\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u0442 \u2014 \u0442\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u0430\u043a\u0435\u0442\u00a0<code>tzdata<\/code>. \u042d\u0442\u043e \u2014 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 CPython. \u0412 \u043d\u0435\u0439 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0430\u0441\u043e\u0432\u044b\u0445 \u043f\u043e\u044f\u0441\u043e\u0432 IANA.<\/p>\n<h3>Dataclasses<\/h3>\n<p>\u0412\u0430\u0436\u043d\u044b\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c Python 3.7 \u0441\u0442\u0430\u043b \u043f\u0430\u043a\u0435\u0442\u00a0<code>dataclasses<\/code>\u00a0(\u043a\u043b\u0430\u0441\u0441\u044b \u0434\u0430\u043d\u043d\u044b\u0445), \u044f\u0432\u043b\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u0437\u0430\u043c\u0435\u043d\u043e\u0439\u00a0<code>namedtuple<\/code>\u00a0(\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439).<\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0443 \u0432\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441 \u043e \u0442\u043e\u043c, \u0437\u0430\u0447\u0435\u043c \u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0430 \u0447\u0442\u043e-\u0442\u043e\u00a0<code>namedtuple<\/code>. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u0447\u0438\u043d \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043d\u0430\u00a0<code>dataclasses<\/code>:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u00ab\u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435\u00bb \u043c\u0435\u0442\u043e\u0434\u044b\u00a0<code>repr<\/code>,\u00a0<code>eq<\/code>,\u00a0<code>init<\/code>,\u00a0<code>hash<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 (\u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Python 3.10) \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b <code>frozen<\/code> \u0438 <code>slots<\/code>, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0438\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430\u00a0<code>dataclasses<\/code>, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432:<\/p>\n<pre><code class=\"python\"># \u0421\u0442\u0430\u0440\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434: # from collections import namedtuple from typing import NamedTuple import sys  User = NamedTuple(\"User\", [(\"name\", str), (\"surname\", str), (\"password\", bytes)])  u = User(\"John\", \"Doe\", b'tfeL+uD...\\xd2') print(f\"Size: {sys.getsizeof(u)}\") # Size: 64  # \u041d\u043e\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434: from dataclasses import dataclass  @dataclass() class User:     name: str     surname: str     password: bytes  u = User(\"John\", \"Doe\", b'tfeL+uD...\\xd2')  print(u) # User(name='John', surname='Doe', password=b'tfeL+uD...\\xd2')  print(f\"Size: {sys.getsizeof(u)}, {sys.getsizeof(u) + sys.getsizeof(vars(u))}\") # Size: 48, 152<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043a\u043e\u0434\u0435, \u043a\u0440\u043e\u043c\u0435 \u043f\u0440\u043e\u0447\u0435\u0433\u043e, \u043c\u044b \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439. \u042d\u0442\u043e \u2014 \u043e\u0434\u043d\u043e \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0439 \u043c\u0435\u0436\u0434\u0443\u00a0<code>namedtuple<\/code>\u00a0\u0438\u00a0<code>dataclasses<\/code>. \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0440\u0442\u0435\u0436\u0430 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043c\u0435\u043d\u044c\u0448\u0435. \u042d\u0442\u043e \u0442\u0430\u043a \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u00a0<code>dict<\/code>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b\u00a0<code>namedtuple<\/code>\u00a0\u0438\u00a0<code>dataclasses<\/code>, \u0442\u043e \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0430\u043a\u043e\u0439 \u0436\u0435, \u043a\u0430\u043a \u0438 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u043c. \u041e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e \u043d\u0430 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0433\u043b\u0430\u0437\u0430, \u043d\u043e \u043b\u0438\u0448\u044c \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043d\u0435 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u044b \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432:<\/p>\n<pre><code class=\"python\">import timeit  setup = ''' from typing import NamedTuple User = NamedTuple(\"User\", [(\"name\", str), (\"surname\", str), (\"password\", bytes)]) u = User(\"John\", \"Doe\", b'') '''  print(f\"Access speed: {min(timeit.repeat('u.name', setup=setup, number=10000000))}\") # Access speed: 0.16838401100540068  setup = ''' from dataclasses import dataclass  @dataclass(slots=True) class User:     name: str     surname: str     password: bytes  u = User(\"John\", \"Doe\", b'') '''  print(f\"Access speed: {min(timeit.repeat('u.name', setup=setup, number=10000000))}\") # Access speed: 0.17728697300481144<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b\u0448\u0435\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0443\u0431\u0435\u0434\u0438\u043b\u043e \u0432\u0430\u0441 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u0432\u044b \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c Python 3.6 \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u043d\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u044f\u0437\u044b\u043a\u0430, \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c <a href=\"https:\/\/pypi.org\/project\/dataclasses\/\">\u0431\u044d\u043a\u043f\u043e\u0440\u0442\u043e\u043c<\/a>.<\/p>\n<p>\u0418 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 \u2014 \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435, \u0435\u0441\u043b\u0438 \u043f\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0432\u0430\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u044b \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u0440\u0442\u0435\u0436\u0438, \u0442\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u0441\u0442\u043e\u0438\u0442, \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <code>NamedTuple<\/code>\u00a0\u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f\u00a0<code>typing<\/code>, \u0430 \u043d\u0435 \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f\u00a0<code>collections<\/code>:<\/p>\n<pre><code class=\"python\"># \u041f\u043b\u043e\u0445\u043e: from collections import namedtuple Point = namedtuple(\"Point\", [\"x\", \"y\"])  # \u041b\u0443\u0447\u0448\u0435: from typing import NamedTuple class Point(NamedTuple):     x: float     y: float<\/code><\/pre>\n<p>\u0418, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435\u0441\u044c \u043d\u0438\u00a0<code>namedtyple<\/code>, \u043d\u0438\u00a0<code>dataclasses<\/code>, \u0442\u043e \u0432\u0430\u043c, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0441\u0442\u043e\u0438\u0442 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u00a0<a href=\"https:\/\/pydantic-docs.helpmanual.io\/\">pydantic<\/a>.<\/p>\n<h3>\u041a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>\u0422\u0443\u0442 \u0440\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0451\u0442 \u043d\u0435 \u043e \u043d\u0435\u043a\u043e\u0435\u043c \u043d\u0435\u0434\u0430\u0432\u043d\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0420\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u044b \u043e \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0435 \u043d\u043e\u0432\u044b, \u043d\u043e \u043d\u0435\u043b\u0438\u0448\u043d\u0438\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043d\u043e\u0432\u0430 \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u044d\u0442\u0443 \u0442\u0435\u043c\u0443: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u043c\u0435\u0441\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439\u00a0<code>print<\/code>. \u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0435\u0441\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0442\u043b\u0430\u0434\u043a\u043e\u0439 \u2014 \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f\u00a0<code>print<\/code>. \u041d\u043e \u0434\u043b\u044f \u0447\u0435\u0433\u043e-\u0442\u043e, \u0443\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0433\u043e \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u0431\u0435\u0437 \u0432\u043c\u0435\u0448\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435.<\/p>\n<p>\u041a \u0442\u043e\u043c\u0443 \u0436\u0435, \u0442\u0430\u043a\u043e\u0435 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u043c\u00a0<code>logging<\/code>\u00a0\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438:<\/p>\n<pre><code class=\"python\">import logging logging.basicConfig(     filename='application.log',     level=logging.WARNING,     format='[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s',     datefmt='%H:%M:%S' )  logging.error(\"Some serious error occurred.\") # [12:52:35] {&lt;stdin>:1} ERROR - Some serious error occurred. logging.warning('Some warning.') # [12:52:35] {&lt;stdin>:1} WARNING - Some warning.<\/code><\/pre>\n<p>\u0414\u0430\u0436\u0435 \u0442\u0430 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0447\u0442\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u0432\u044b\u0448\u0435, \u0434\u0430\u0441\u0442, \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0441\u00a0<code>print<\/code>, \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e\u0435 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u0435 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043e\u0442\u043b\u0430\u0434\u043a\u0438. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <code>logging<\/code> \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0438 \u0434\u0430\u043b\u044c\u0448\u0435, \u0441\u0434\u0435\u043b\u0430\u0432 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043b\u043e\u0433\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u043b\u0438\u0441\u044c \u0431\u044b \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430, \u0437\u0430\u0434\u0430\u0432\u0430\u044f \u0443\u0440\u043e\u0432\u043d\u0438 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0440\u043e\u0442\u0430\u0446\u0438\u044e \u043b\u043e\u0433\u043e\u0432 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0432\u0441\u0451 \u044d\u0442\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c, \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0432 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043c\u043e\u0438\u0445 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445\u00a0<a href=\"https:\/\/martinheinz.dev\/blog\/24\">\u0441\u0442\u0430\u0442\u0435\u0439<\/a>, \u043f\u043e\u0441\u0432\u044f\u0449\u0451\u043d\u043d\u043e\u0439 \u043e\u0442\u043b\u0430\u0434\u043a\u0435 \u0432 Python.<\/p>\n<h3>F-\u0441\u0442\u0440\u043e\u043a\u0438<\/h3>\n<p>\u0412 Python \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a. \u0421\u044e\u0434\u0430 \u0432\u0445\u043e\u0434\u0438\u0442 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0441\u0442\u0438\u043b\u0435 C, f-\u0441\u0442\u0440\u043e\u043a\u0438, \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u00a0<code>.format<\/code>. \u0421\u0440\u0435\u0434\u0438 \u044d\u0442\u0438\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c f-\u0441\u0442\u0440\u043e\u043a\u0438 (f-strings), \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044b. \u042d\u0442\u043e \u2014 \u043d\u0435\u0447\u0442\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435. \u041e\u043d\u0438, \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a, \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0432 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438, \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u0435\u0435, \u0430 \u0435\u0449\u0451 \u2014 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445.<\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u044f \u043f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u0447\u0442\u043e-\u0442\u043e \u0434\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c, \u0430\u0433\u0438\u0442\u0438\u0440\u0443\u044f \u0437\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 f-\u0441\u0442\u0440\u043e\u043a. \u041f\u0440\u0430\u0432\u0434\u0430, \u0435\u0441\u0442\u044c \u043f\u0430\u0440\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439, \u043a\u043e\u0433\u0434\u0430 f-\u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f.<\/p>\n<p>\u0422\u0430\u043a, \u043e\u0434\u043d\u0430 \u0438\u0437 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c\u00a0<code>%<\/code>\u00a0\u2014 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"python\">import logging  things = \"something happened...\"  logger = logging.getLogger(__name__) logger.error(\"Message: %s\", things)  # \u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f logger.error(f\"Message: {things}\")  # \u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u0435\u0441\u043b\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f f-\u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438, \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043e \u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e. \u0410 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u0442\u0438\u043b\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f C \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0442\u043b\u043e\u0436\u0438\u0442\u044c \u0437\u0430\u043c\u0435\u043d\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e \u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e. \u042d\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 \u043e\u0434\u043d\u0438\u043c \u0438 \u0442\u0435\u043c \u0436\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u043a \u043e\u0434\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435. \u0410 \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c f-\u0441\u0442\u0440\u043e\u043a \u0442\u0430\u043a \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u0448\u0430\u0431\u043b\u043e\u043d \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0435\u0441\u0442\u044c \u0432\u0435\u0449\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 f-\u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0443\u043c\u0435\u044e\u0442. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u2014 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0442\u043e \u0435\u0441\u0442\u044c \u2014 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 f-\u0441\u0442\u0440\u043e\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u0432:<\/p>\n<pre><code class=\"python\"># \u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430, \u0438 \u0435\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 def func(tpl: str, param1: str, param2: str) -> str:     return tpl.format(param=param1, param2=param2)  some_template = \"First template: {param1}, {param2}\" another_template = \"Other template: {param1} and {param2}\"  print(func(some_template, \"Hello\", \"World\")) print(func(another_template, \"Hello\", \"Python\"))  # \u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 inputs = [\"Hello\", \"World\", \"!\"] template = \"Here's some dynamic value: {value}\"  for value in inputs:     print(template.format(value=value))<\/code><\/pre>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c f-\u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u0435\u0437\u0434\u0435, \u0433\u0434\u0435 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0438 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u0435\u0435 \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u0432 Python. \u041d\u043e \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043b\u0443\u0447\u0448\u0435 (\u0438\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e) \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430\u043c\u0438.<\/p>\n<blockquote>\n<p>\u0427\u0438\u0442\u0430\u0439\u0442\u0435 \u00ab<a href=\"https:\/\/habr.com\/ru\/company\/wunderfund\/blog\/674866\/\">F-\u0441\u0442\u0440\u043e\u043a\u0438 \u0432 Python \u043c\u043e\u0449\u043d\u0435\u0435, \u0447\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c<\/a>\u00bb \u0443 \u043d\u0430\u0441 \u0432 \u0431\u043b\u043e\u0433\u0435<\/p>\n<\/blockquote>\n<h3>Tomllib<\/h3>\n<p>TOML \u2014 \u044d\u0442\u043e \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u0435\u043d \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 Python-\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0438, \u0432 \u0446\u0435\u043b\u043e\u043c, \u0432 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0435 Python. \u0412\u0441\u0451 \u0434\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430\u0445\u00a0<code>pyproject.toml<\/code>. \u0414\u043e \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f TOML-\u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u041d\u043e, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441\u00a0<a href=\"https:\/\/peps.python.org\/pep-0680\/\">Python 3.11<\/a>, \u0432 \u043d\u0430\u0448\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u0440\u044f\u0436\u0435\u043d\u0438\u0438 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043d\u0430\u0437\u0432\u0430\u043d\u043d\u0430\u044f <code>tomllib<\/code>, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043d\u0430 \u043f\u0430\u043a\u0435\u0442\u0435\u00a0<code>tomli<\/code>.<\/p>\n<p>\u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u0442\u0435 \u043d\u0430 Python 3.11, \u0443 \u0432\u0430\u0441 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0438\u0432\u044b\u0447\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>import tomllib<\/code>\u00a0\u0432\u043c\u0435\u0441\u0442\u043e\u00a0<code>import tomli<\/code>. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0437\u0430\u0431\u043e\u0442\u0438\u0442\u044c\u0441\u044f \u043e \u043c\u0435\u043d\u044c\u0448\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430!<\/p>\n<pre><code class=\"python\"># import tomli as tomllib import tomllib  with open(\"pyproject.toml\", \"rb\") as f:     config = tomllib.load(f)     print(config)     # {'project': {'authors': [{'email': 'contact@martinheinz.dev',     #                           'name': 'Martin Heinz'}],     #              'dependencies': ['flask', 'requests'],     #              'description': 'Example Package',     #              'name': 'some-app',     #              'version': '0.1.0'}}  toml_string = \"\"\" [project] name = \"another-app\" description = \"Example Package\" version = \"0.1.1\" \"\"\"  config = tomllib.loads(toml_string) print(config) # {'project': {'name': 'another-app', 'description': 'Example Package', 'version': '0.1.1'}}<\/code><\/pre>\n<h3>Setuptools<\/h3>\n<p>\u041d\u0430\u0448 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0440\u0430\u0437\u0434\u0435\u043b \u043f\u043e\u0441\u0432\u044f\u0449\u0451\u043d, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c, \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044e \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0430\u043a\u0435\u0442 <code>distutils<\/code> \u043f\u0440\u0438\u0437\u043d\u0430\u043d \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u043c:<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043f\u0430\u043a\u0435\u0442\u00a0<code>distutils<\/code>\u00a0\u043f\u0440\u0438\u0437\u043d\u0430\u043d \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u043c, \u043b\u044e\u0431\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430 \u043d\u0435 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442\u0441\u044f. \u041f\u0430\u043a\u0435\u0442\u00a0<code>setuptools<\/code>\u00a0\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u043d\u0430 \u0437\u0430\u043c\u0435\u043d\u0443 \u0438\u043b\u0438 \u0432\u044b\u0432\u043e\u0434 \u0438\u0437 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432.<\/p>\n<p>\u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u043f\u0440\u043e\u0449\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u0430\u043a\u0435\u0442\u043e\u043c\u00a0<code>distutils<\/code>\u00a0\u0438 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 <code>setuptools<\/code>. <a href=\"https:\/\/setuptools.pypa.io\/en\/latest\/deprecated\/distutils-legacy.html\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f<\/a> \u043f\u043e\u00a0<code>setuptools<\/code>\u00a0\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0441 <code>distutils<\/code> \u043d\u0430 <code>setuptools<\/code>. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0432 PEP 632 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438\u00a0<a href=\"https:\/\/peps.python.org\/pep-0632\/#migration-advice\">\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u043f\u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438<\/a>\u00a0\u0441 \u0442\u0435\u0445 \u0447\u0430\u0441\u0442\u0435\u0439\u00a0<code>distutils<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u00a0<code>setuptools<\/code>.<\/p>\n<h3>\u0418\u0442\u043e\u0433\u0438<\/h3>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u043d\u043e\u0432\u044b\u0439 \u0440\u0435\u043b\u0438\u0437 Python \u043d\u0435\u0441\u0451\u0442 \u0432 \u0441\u0435\u0431\u0435 \u043d\u043e\u0432\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e, \u0437\u0430\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u044f \u0432 \u043f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u044f \u043a \u0432\u044b\u043f\u0443\u0441\u043a\u0443 (<a href=\"https:\/\/docs.python.org\/3\/whatsnew\/3.9.html#new-modules\">release notes<\/a>) Python, \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u044b \u00ab\u041d\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438\u00bb (New Modules), \u00ab\u0423\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438\u00bb (Deprecated modules) \u0438 \u00ab\u0423\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438\u00bb (Removed modules). \u042d\u0442\u043e \u2014 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u0443\u0440\u0441\u0435 \u043a\u0440\u0443\u043f\u043d\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Python. \u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u0441\u0432\u043e\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u043d\u043e\u0432\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u044f\u043c \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435.<\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u0430\u043c \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b. \u041d\u043e, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e\u00a0<code>pyupgrade<\/code>. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442, \u0442\u0430\u043c, \u0433\u0434\u0435 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u0434\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 Python.<\/p>\n<details class=\"spoiler\">\n<summary>\u041e, \u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0435 \u043a \u043d\u0430\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c? ? ?<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041c\u044b \u0432\u00a0<a href=\"http:\/\/wunderfund.io\/\"><strong>wunderfund.io<\/strong><\/a>\u00a0\u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u0441\u044f\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/High-frequency_trading\">\u0432\u044b\u0441\u043e\u043a\u043e\u0447\u0430\u0441\u0442\u043e\u0442\u043d\u043e\u0439 \u0430\u043b\u0433\u043e\u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0435\u0439<\/a>\u00a0\u0441 2014 \u0433\u043e\u0434\u0430. \u0412\u044b\u0441\u043e\u043a\u043e\u0447\u0430\u0441\u0442\u043e\u0442\u043d\u0430\u044f \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u044f \u2014 \u044d\u0442\u043e \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e\u0435 \u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043b\u0443\u0447\u0448\u0438\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 \u0438 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u043e\u0432 \u0432\u0441\u0435\u0433\u043e \u043c\u0438\u0440\u0430. \u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0432\u0448\u0438\u0441\u044c \u043a \u043d\u0430\u043c, \u0432\u044b \u0441\u0442\u0430\u043d\u0435\u0442\u0435 \u0447\u0430\u0441\u0442\u044c\u044e \u044d\u0442\u043e\u0439 \u0443\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0445\u0432\u0430\u0442\u043a\u0438.<\/p>\n<p>\u041c\u044b \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 low latency \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0434\u043b\u044f \u0443\u0432\u043b\u0435\u0447\u0435\u043d\u043d\u044b\u0445 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432. \u0413\u0438\u0431\u043a\u0438\u0439 \u0433\u0440\u0430\u0444\u0438\u043a \u0438 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0431\u044e\u0440\u043e\u043a\u0440\u0430\u0442\u0438\u0438, \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u0438 \u0432\u043e\u043f\u043b\u043e\u0449\u0430\u044e\u0442\u0441\u044f \u0432 \u0436\u0438\u0437\u043d\u044c.<\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0438\u0449\u0435\u043c \u043f\u043b\u044e\u0441\u043e\u0432\u0438\u043a\u043e\u0432, \u043f\u0438\u0442\u043e\u043d\u0438\u0441\u0442\u043e\u0432, \u0434\u0430\u0442\u0430-\u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043e\u0432 \u0438 \u043c\u043b-\u0440\u0438\u0441\u0435\u0440\u0447\u0435\u0440\u043e\u0432.<\/p>\n<p><a href=\"http:\/\/wunderfund.io\/#join_us\">\u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435\u0441\u044c \u043a \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435.<\/a><\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/company\/wunderfund\/blog\/681284\/\"> https:\/\/habr.com\/ru\/company\/wunderfund\/blog\/681284\/<\/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>\u0412 Python, \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u0440\u0435\u043b\u0438\u0437\u043e\u043c, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u043d\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u0438 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447. \u0412\u0441\u0435 \u043c\u044b \u043f\u0440\u0438\u0432\u044b\u043a\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0442\u0430\u0440\u044b\u043c\u0438 \u0434\u043e\u0431\u0440\u044b\u043c\u0438 Python-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438, \u043f\u0440\u0438\u0432\u044b\u043a\u043b\u0438 \u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c \u0440\u0430\u0431\u043e\u0442\u044b. \u041d\u043e \u043f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f, \u0432\u0440\u0435\u043c\u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u043e\u0432\u044b\u043c\u0438 \u0438 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u043d\u044b\u043c\u0438 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438 \u0438 \u0438\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>Pathlib<\/h3>\n<p>\u041c\u043e\u0434\u0443\u043b\u044c\u00a0<code>pathlib<\/code>\u00a0\u2014 \u044d\u0442\u043e, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e, \u043e\u0434\u043d\u043e \u0438\u0437 \u043a\u0440\u0443\u043f\u043d\u0435\u0439\u0448\u0438\u0445 \u043d\u0435\u0434\u0430\u0432\u043d\u0438\u0445 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Python. \u042d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u0441\u0442\u0430\u043b \u0447\u0430\u0441\u0442\u044c\u044e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Python 3.4. \u041f\u0440\u0430\u0432\u0434\u0430, \u043c\u043d\u043e\u0433\u0438\u0435 \u0432\u0441\u0451 \u0435\u0449\u0451 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u043c\u00a0<code>os<\/code>\u00a0\u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439.<\/p>\n<p>\u041d\u043e \u043c\u043e\u0434\u0443\u043b\u044c\u00a0<code>pathlib<\/code>, \u0432\u0441\u0451 \u0436\u0435, \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u043b\u0443\u0447\u0448\u0435 \u0441\u0442\u0430\u0440\u043e\u0433\u043e\u00a0<code>os.path<\/code>. \u0422\u0430\u043a, \u043c\u043e\u0434\u0443\u043b\u044c <code>os<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0443\u0442\u0438 \u0432 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0432 \u0432\u0438\u0434\u0435 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a, \u0430 \u0432\u00a0<code>pathlib<\/code>\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u0442\u0438\u043b\u044c. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442\u0441\u044f \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0435\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"python\">from pathlib import Path import os.path  # \u0421\u0442\u0430\u0440\u044b\u0439 \u043a\u043e\u0434 \u0441 \u043f\u043b\u043e\u0445\u043e\u0439 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e two_dirs_up = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # \u041d\u043e\u0432\u044b\u0439, \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 two_dirs_up = Path(__file__).resolve().parent.parent<\/code><\/pre>\n<p>\u0422\u043e\u0442 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u043f\u0443\u0442\u0438 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0430 \u043d\u0435 \u043a\u0430\u043a \u0441\u0442\u0440\u043e\u043a\u0438, \u0434\u0435\u043b\u0430\u0435\u0442, \u043a\u0440\u043e\u043c\u0435 \u043f\u0440\u043e\u0447\u0435\u0433\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0435\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c \u0438\u043b\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u043d\u0438\u043c\u0438:<\/p>\n<pre><code class=\"python\">readme = Path(\"README.md\").resolve()  print(f\"Absolute path: {readme.absolute()}\") # Absolute path: \/home\/martin\/some\/path\/README.md print(f\"File name: {readme.name}\") # File name: README.md print(f\"Path root: {readme.root}\") # Path root: \/ print(f\"Parent directory: {readme.parent}\") # Parent directory: \/home\/martin\/some\/path print(f\"File extension: {readme.suffix}\") # File extension: .md print(f\"Is it absolute: {readme.is_absolute()}\") # Is it absolute: True<\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430 \u0438\u0437 \u043c\u043e\u0438\u0445 \u043b\u044e\u0431\u0438\u043c\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439\u00a0<code>pathlib<\/code>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u0445\u043e\u0447\u0443 \u043e\u0441\u043e\u0431\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u044d\u0442\u043e \u2014 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u00a0<code>\/<\/code>\u00a0(\u043e\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u00ab\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u00bb) \u0434\u043b\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043f\u0443\u0442\u0435\u0439:<\/p>\n<pre><code class=\"python\"># \u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b: etc = Path('\/etc')  joined = etc \/ \"cron.d\" \/ \"anacron\" print(f\"Exists? - {joined.exists()}\") # Exists? - True<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0432\u0435\u0441\u044c\u043c\u0430 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043f\u0443\u0442\u044f\u043c\u0438. \u042d\u0442\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u2014 \u043d\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0438\u0448\u0435\u043d\u043a\u0430 \u043d\u0430 \u00ab\u0442\u043e\u0440\u0442\u0435\u00bb <code>pathlib<\/code>.<\/p>\n<p>\u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u044d\u0442\u043e \u2014 \u0432\u0430\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u043e\u0434\u0443\u043b\u044c\u00a0<code>pathlib<\/code>\u00a0\u2014 \u044d\u0442\u043e \u0437\u0430\u043c\u0435\u043d\u0430 \u043b\u0438\u0448\u044c \u0434\u043b\u044f\u00a0<code>os.path<\/code>, \u0430 \u043d\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f\u00a0<code>os<\/code>. \u0412\u00a0<code>pathlib<\/code>, \u043f\u0440\u0430\u0432\u0434\u0430, \u0432\u043a\u043b\u044e\u0447\u0451\u043d \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f\u00a0<code>glob<\/code>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u0440\u0438\u0432\u044b\u043a\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f\u00a0<code>os.path<\/code>\u00a0\u0432 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0441\u00a0<code>glob.glob<\/code>, \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e, \u043f\u0435\u0440\u0435\u0439\u0434\u044f \u043d\u0430\u00a0<code>pathlib<\/code>, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0431\u044b\u0442\u044c \u043e\u0431 \u0438\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0438.<\/p>\n<p>\u0412 \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u043f\u0440\u0438\u0451\u043c\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0443\u0442\u044f\u043c\u0438 \u0438 \u0441 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u043f\u0443\u0442\u044c. \u041d\u043e \u0432\u00a0<code>pathlib<\/code>\u00a0\u0438\u043c\u0435\u044e\u0442\u0441\u044f \u0435\u0449\u0451 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b, \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0435 \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441\u00a0<code>os.path<\/code>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"python\">print(f\"Working directory: {Path.cwd()}\")  # \u0442\u043e \u0436\u0435, \u0447\u0442\u043e os.getcwd() # Working directory: \/home\/martin\/some\/path Path.mkdir(Path.cwd() \/ \"new_dir\", exist_ok=True)  # \u0442\u043e \u0436\u0435, \u0447\u0442\u043e os.makedirs() print(Path(\"README.md\").resolve())  # \u0442\u043e \u0436\u0435, \u0447\u0442\u043e os.path.abspath() # \/home\/martin\/some\/path\/README.md print(Path.home())  # \u0442\u043e \u0436\u0435, \u0447\u0442\u043e os.path.expanduser() # \/home\/martin<\/code><\/pre>\n<p>\u041f\u043e\u043b\u043d\u044b\u0435 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439\u00a0<code>os.path<\/code>\u00a0\u0438 \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438\u0437\u00a0<code>pathlib<\/code>\u00a0\u0438\u043c\u0435\u044e\u0442\u0441\u044f \u0432\u00a0<a href=\"https:\/\/docs.python.org\/3\/library\/pathlib.html#correspondence-to-tools-in-the-os-module\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<p>\u0411\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430\u00a0<code>pathlib<\/code>, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432\u00a0<a href=\"https:\/\/treyhunner.com\/2018\/12\/why-you-should-be-using-pathlib\/\">\u044d\u0442\u043e\u0439<\/a>\u00a0\u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<h3>Secrets<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440 \u043e \u043c\u043e\u0434\u0443\u043b\u0435\u00a0<code>os<\/code>, \u0442\u043e \u0435\u0449\u0451 \u043e\u0434\u043d\u0430 \u0435\u0433\u043e \u0447\u0430\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u043f\u043e\u043a\u043e\u0439 \u2014 \u044d\u0442\u043e\u00a0<code>os.urandom<\/code>. \u0412\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0451 \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c\u00a0<code>secrets<\/code>, \u0438\u043c\u0435\u044e\u0449\u0438\u0439\u0441\u044f \u0432 \u043d\u0430\u0448\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u0440\u044f\u0436\u0435\u043d\u0438\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Python 3.6:<\/p>\n<pre><code class=\"python\"># \u0421\u0442\u0430\u0440\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434: import os  length = 64  value = os.urandom(length) print(f\"Bytes: {value}\") # Bytes: b'\\xfa\\xf3...\\xf2\\x1b\\xf5\\xb6' print(f\"Hex: {value.hex()}\") # Hex: faf3cc656370e31a938e7...33d9b023c3c24f1bf5  # \u041d\u043e\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434: import secrets  value = secrets.token_bytes(length) print(f\"Bytes: {value}\") # Bytes: b'U\\xe9n\\x87...\\x85>\\x04j:\\xb0' value = secrets.token_hex(length) print(f\"Hex: {value}\") # Hex: fb5dd85e7d73f7a08b8e3...4fd9f95beb08d77391<\/code><\/pre>\n<p>\u0422\u0443\u0442, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u043c\u043e\u0434\u0443\u043b\u044c\u00a0<code>os.urandom<\/code>. \u041d\u043e <a href=\"https:\/\/peps.python.org\/pep-0506\/#rationale\">\u043f\u0440\u0438\u0447\u0438\u043d\u0430<\/a> \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u044f\u00a0<code>secrets<\/code>\u00a0\u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043c\u043e\u0434\u0443\u043b\u044c <code>random<\/code>\u00a0\u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u0440\u043e\u043b\u0435\u0439 \u0438 \u043f\u0440\u043e\u0447\u0435\u0433\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e. \u0418 \u044d\u0442\u043e \u2014 \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043c\u043e\u0434\u0443\u043b\u044c\u00a0<code>random<\/code>\u00a0\u043d\u0435 \u0432\u044b\u0434\u0430\u0451\u0442 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u0442\u043e\u043a\u0435\u043d\u044b.<\/p>\n<p>\u041c\u043e\u0434\u0443\u043b\u044c\u00a0<code>random<\/code>, \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439, \u043d\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0446\u0435\u043b\u0435\u0439, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c\u044e. \u041d\u0430\u0434\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043b\u0438\u0431\u043e\u00a0<code>secrets<\/code>, \u043b\u0438\u0431\u043e\u00a0<code>os.urandom<\/code>. \u041d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0435\u043d\u0438\u0435, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e, \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u0434\u0430\u0442\u044c\u00a0<code>secrets<\/code>, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0442\u043e, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u043d\u043e\u0432\u0435\u0435, \u0438 \u0442\u043e, \u0447\u0442\u043e \u043e\u043d \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0442\u0438\u043b\u0438\u0442\u044b\/\u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0448\u0435\u0441\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u0435\u0440\u0438\u0447\u043d\u044b\u043c\u0438 \u0442\u043e\u043a\u0435\u043d\u0430\u043c\u0438, \u0430 \u0442\u0430\u043a \u0436\u0435 \u2014 \u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 URL-\u0430\u0434\u0440\u0435\u0441\u0430\u043c\u0438, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u043c\u0438 \u043c\u0430\u0440\u043a\u0435\u0440 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438.<\/p>\n<h3>Zoneinfo<\/h3>\n<p>\u0414\u043e Python 3.9 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043c\u043e\u0434\u0443\u043b\u044f \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u0430\u0442\u044b \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0447\u0430\u0441\u043e\u0432\u044b\u043c\u0438 \u043f\u043e\u044f\u0441\u0430\u043c\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043c\u043e\u0434\u0443\u043b\u0435\u043c\u00a0<code>pytz<\/code>. \u041d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u044c <code>zoneinfo<\/code>. \u0410 \u0437\u043d\u0430\u0447\u0438\u0442 \u2014 \u043f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0435\u0433\u043e!<\/p>\n<pre><code class=\"python\">from datetime import datetime import pytz  # pip install pytz  dt = datetime(2022, 6, 4) nyc = pytz.timezone(\"America\/New_York\")  localized = nyc.localize(dt) print(f\"Datetime: {localized}, Timezone: {localized.tzname()}, TZ Info: {localized.tzinfo}\")  # \u041f\u043e-\u043d\u043e\u0432\u043e\u043c\u0443: from zoneinfo import ZoneInfo  nyc = ZoneInfo(\"America\/New_York\") localized = datetime(2022, 6, 4, tzinfo=nyc) print(f\"Datetime: {localized}, Timezone: {localized.tzname()}, TZ Info: {localized.tzinfo}\") # Datetime: 2022-06-04 00:00:00-04:00, Timezone: EDT, TZ Info: America\/New_York<\/code><\/pre>\n<p>\u041c\u043e\u0434\u0443\u043b\u044c\u00a0<code>datetime<\/code>\u00a0\u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0435 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 \u0447\u0430\u0441\u043e\u0432\u044b\u043c\u0438 \u043f\u043e\u044f\u0441\u0430\u043c\u0438 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u043c\u0443 \u0431\u0430\u0437\u043e\u0432\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443\u00a0<code>datetime.tzinfo<\/code>. \u042d\u0442\u043e\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043d\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0414\u043e \u0432\u044b\u0445\u043e\u0434\u0430 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0442\u0430\u043a\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u043f\u043e \u0432\u0441\u0435\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438, \u0431\u0440\u0430\u043b\u0438 \u0438\u0437 <code>pytz<\/code>. \u0410 \u0442\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0435\u0441\u0442\u044c\u00a0<code>zoneinfo<\/code>, \u044d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u043e\u00a0<code>pytz<\/code>.<\/p>\n<p>\u0423 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u00a0<code>zoneinfo<\/code>, \u043f\u0440\u0430\u0432\u0434\u0430, \u0435\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u043d\u044e\u0430\u043d\u0441: \u043c\u043e\u0434\u0443\u043b\u044c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442, \u0447\u0442\u043e \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0438\u043c\u0435\u044e\u0442\u0441\u044f \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e \u0447\u0430\u0441\u043e\u0432\u044b\u0445 \u043f\u043e\u044f\u0441\u0430\u0445. \u0412 UNIX-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u044d\u0442\u043e \u0442\u0430\u043a. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0432 \u0432\u0430\u0448\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0442\u0430\u043a\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u0442 \u2014 \u0442\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u0430\u043a\u0435\u0442\u00a0<code>tzdata<\/code>. \u042d\u0442\u043e \u2014 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 CPython. \u0412 \u043d\u0435\u0439 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0430\u0441\u043e\u0432\u044b\u0445 \u043f\u043e\u044f\u0441\u043e\u0432 IANA.<\/p>\n<h3>Dataclasses<\/h3>\n<p>\u0412\u0430\u0436\u043d\u044b\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c Python 3.7 \u0441\u0442\u0430\u043b \u043f\u0430\u043a\u0435\u0442\u00a0<code>dataclasses<\/code>\u00a0(\u043a\u043b\u0430\u0441\u0441\u044b \u0434\u0430\u043d\u043d\u044b\u0445), \u044f\u0432\u043b\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u0437\u0430\u043c\u0435\u043d\u043e\u0439\u00a0<code>namedtuple<\/code>\u00a0(\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439).<\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0443 \u0432\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441 \u043e \u0442\u043e\u043c, \u0437\u0430\u0447\u0435\u043c \u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0430 \u0447\u0442\u043e-\u0442\u043e\u00a0<code>namedtuple<\/code>. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u0447\u0438\u043d \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043d\u0430\u00a0<code>dataclasses<\/code>:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u00ab\u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435\u00bb \u043c\u0435\u0442\u043e\u0434\u044b\u00a0<code>repr<\/code>,\u00a0<code>eq<\/code>,\u00a0<code>init<\/code>,\u00a0<code>hash<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 (\u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Python 3.10) \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b <code>frozen<\/code> \u0438 <code>slots<\/code>, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0438\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430\u00a0<code>dataclasses<\/code>, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432:<\/p>\n<pre><code class=\"python\"># \u0421\u0442\u0430\u0440\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434: # from collections import namedtuple from typing import NamedTuple import sys  User = NamedTuple(\"User\", [(\"name\", str), (\"surname\", str), (\"password\", bytes)])  u = User(\"John\", \"Doe\", b'tfeL+uD...\\xd2') print(f\"Size: {sys.getsizeof(u)}\") # Size: 64  # \u041d\u043e\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434: from dataclasses import dataclass  @dataclass() class User:     name: str     surname: str     password: bytes  u = User(\"John\", \"Doe\", b'tfeL+uD...\\xd2')  print(u) # User(name='John', surname='Doe', password=b'tfeL+uD...\\xd2')  print(f\"Size: {sys.getsizeof(u)}, {sys.getsizeof(u) + sys.getsizeof(vars(u))}\") # Size: 48, 152<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043a\u043e\u0434\u0435, \u043a\u0440\u043e\u043c\u0435 \u043f\u0440\u043e\u0447\u0435\u0433\u043e, \u043c\u044b \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439. \u042d\u0442\u043e \u2014 \u043e\u0434\u043d\u043e \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0439 \u043c\u0435\u0436\u0434\u0443\u00a0<code>namedtuple<\/code>\u00a0\u0438\u00a0<code>dataclasses<\/code>. \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0440\u0442\u0435\u0436\u0430 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043c\u0435\u043d\u044c\u0448\u0435. \u042d\u0442\u043e \u0442\u0430\u043a \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u00a0<code>dict<\/code>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b\u00a0<code>namedtuple<\/code>\u00a0\u0438\u00a0<code>dataclasses<\/code>, \u0442\u043e \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0430\u043a\u043e\u0439 \u0436\u0435, \u043a\u0430\u043a \u0438 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u043c. \u041e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e \u043d\u0430 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0433\u043b\u0430\u0437\u0430, \u043d\u043e \u043b\u0438\u0448\u044c \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043d\u0435 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u044b \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432:<\/p>\n<pre><code class=\"python\">import timeit  setup = ''' from typing import NamedTuple User = NamedTuple(\"User\", [(\"name\", str), (\"surname\", str), (\"password\", bytes)]) u = User(\"John\", \"Doe\", b'') '''  print(f\"Access speed: {min(timeit.repeat('u.name', setup=setup, number=10000000))}\") # Access speed: 0.16838401100540068  setup = ''' from dataclasses import dataclass  @dataclass(slots=True) class User:     name: str     surname: str     password: bytes  u = User(\"John\", \"Doe\", b'') '''  print(f\"Access speed: {min(timeit.repeat('u.name', setup=setup, number=10000000))}\") # Access speed: 0.17728697300481144<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b\u0448\u0435\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0443\u0431\u0435\u0434\u0438\u043b\u043e \u0432\u0430\u0441 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u0432\u044b \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c Python 3.6 \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u043d\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u044f\u0437\u044b\u043a\u0430, \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c <a href=\"https:\/\/pypi.org\/project\/dataclasses\/\">\u0431\u044d\u043a\u043f\u043e\u0440\u0442\u043e\u043c<\/a>.<\/p>\n<p>\u0418 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 \u2014 \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435, \u0435\u0441\u043b\u0438 \u043f\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0432\u0430\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u044b \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u0440\u0442\u0435\u0436\u0438, \u0442\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u0441\u0442\u043e\u0438\u0442, \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <code>NamedTuple<\/code>\u00a0\u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f\u00a0<code>typing<\/code>, \u0430 \u043d\u0435 \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f\u00a0<code>collections<\/code>:<\/p>\n<pre><code class=\"python\"># \u041f\u043b\u043e\u0445\u043e: from collections import namedtuple Point = namedtuple(\"Point\", [\"x\", \"y\"])  # \u041b\u0443\u0447\u0448\u0435: from typing import NamedTuple class Point(NamedTuple):     x: float     y: float<\/code><\/pre>\n<p>\u0418, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435\u0441\u044c \u043d\u0438\u00a0<code>namedtyple<\/code>, \u043d\u0438\u00a0<code>dataclasses<\/code>, \u0442\u043e \u0432\u0430\u043c, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0441\u0442\u043e\u0438\u0442 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u00a0<a href=\"https:\/\/pydantic-docs.helpmanual.io\/\">pydantic<\/a>.<\/p>\n<h3>\u041a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>\u0422\u0443\u0442 \u0440\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0451\u0442 \u043d\u0435 \u043e \u043d\u0435\u043a\u043e\u0435\u043c \u043d\u0435\u0434\u0430\u0432\u043d\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0420\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u044b \u043e \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0435 \u043d\u043e\u0432\u044b, \u043d\u043e \u043d\u0435\u043b\u0438\u0448\u043d\u0438\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043d\u043e\u0432\u0430 \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u044d\u0442\u0443 \u0442\u0435\u043c\u0443: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u043c\u0435\u0441\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439\u00a0<code>print<\/code>. \u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0435\u0441\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0442\u043b\u0430\u0434\u043a\u043e\u0439 \u2014 \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f\u00a0<code>print<\/code>. \u041d\u043e \u0434\u043b\u044f \u0447\u0435\u0433\u043e-\u0442\u043e, \u0443\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0433\u043e \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u0431\u0435\u0437 \u0432\u043c\u0435\u0448\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435.<\/p>\n<p>\u041a \u0442\u043e\u043c\u0443 \u0436\u0435, \u0442\u0430\u043a\u043e\u0435 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u043c\u00a0<code>logging<\/code>\u00a0\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438:<\/p>\n<pre><code class=\"python\">impor<\/code><\/pre>\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-336740","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/336740","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=336740"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/336740\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=336740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=336740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=336740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}