> **Источник:** https://python-all.ru/3.0/tutorial/index.html
>
> «Документация Python на русском» – неофициальный перевод официальной документации Python: версии от 2.6 до 3.16, полнотекстовый поиск, английский оригинал рядом с переводом. Эта Markdown-версия страницы предназначена для работы с LLM: вставьте её в ChatGPT, Claude или Cursor.

---

# Учебник Python

| Версия: | 3.0 |
| --- | --- |
| Дата: | 14 февраля 2009 |

Python – это простой для изучения, но мощный язык программирования. В нём эффективные высокоуровневые структуры данных и простой, но эффективный подход к объектно-ориентированному программированию. Элегантный синтаксис Python, динамическая типизация в сочетании с интерпретируемостью делают его идеальным языком для написания сценариев и быстрой разработки приложений в самых разных областях на большинстве платформ.

Интерпретатор Python и обширная стандартная библиотека доступны бесплатно в исходном или двоичном виде для всех основных платформ на сайте Python, [http://www.python.org/](https://python-all.ru/3.0/tutorial/index.html), и могут свободно распространяться. На этом же сайте также размещены дистрибутивы и ссылки на множество бесплатных сторонних модулей Python, программ и инструментов, а также дополнительная документация.

Интерпретатор Python легко расширяется новыми функциями и типами данных, реализованными на C или C++ (или других языках, вызываемых из C). Python также подходит как язык расширения для настраиваемых приложений.

Этот учебник в неформальной манере знакомит с основными понятиями и особенностями языка Python и его системы. Желательно иметь под рукой интерпретатор Python для получения практического опыта, но все примеры самодостаточны, поэтому учебник можно читать и в автономном режиме.

Описание стандартных объектов и модулей см. в документе «Справочник по библиотеке Python». В «Справочном руководстве по Python» дано более формальное определение языка. Для написания расширений на C или C++ читайте «Расширение и встраивание интерпретатора Python» и «Справочник по Python/C API». Также существует несколько книг, подробно освещающих Python.

Данное руководство не пытается быть исчерпывающим и охватить каждую отдельную возможность или даже каждую часто используемую возможность. Вместо этого оно знакомит с наиболее примечательными возможностями Python и даёт представление о духе и стиле языка. После его прочтения вы сможете читать и писать модули и программы на Python, а также будете готовы узнать больше о различных модулях библиотеки Python, описанных в «Справочнике по библиотеке Python».

[*Глоссарий*](https://python-all.ru/3.0/glossary.html#glossary) тоже стоит просмотреть.

- [Разжигание аппетита](https://python-all.ru/3.0/tutorial/appetite.html)
- [Использование интерпретатора Python](https://python-all.ru/3.0/tutorial/interpreter.html)

  - [Запуск интерпретатора](https://python-all.ru/3.0/tutorial/interpreter.html#invoking-the-interpreter)

    - [Передача аргументов](https://python-all.ru/3.0/tutorial/interpreter.html#argument-passing)
    - [Интерактивный режим](https://python-all.ru/3.0/tutorial/interpreter.html#interactive-mode)
  - [Интерпретатор и его окружение](https://python-all.ru/3.0/tutorial/interpreter.html#the-interpreter-and-its-environment)

    - [Обработка ошибок](https://python-all.ru/3.0/tutorial/interpreter.html#error-handling)
    - [Исполняемые скрипты Python](https://python-all.ru/3.0/tutorial/interpreter.html#executable-python-scripts)
    - [Кодировка исходного кода](https://python-all.ru/3.0/tutorial/interpreter.html#source-code-encoding)
    - [Интерактивный файл запуска](https://python-all.ru/3.0/tutorial/interpreter.html#the-interactive-startup-file)
- [Неофициальное введение в Python](https://python-all.ru/3.0/tutorial/introduction.html)

  - [Использование Python как калькулятора](https://python-all.ru/3.0/tutorial/introduction.html#using-python-as-a-calculator)

    - [Числа](https://python-all.ru/3.0/tutorial/introduction.html#numbers)
    - [Строки](https://python-all.ru/3.0/tutorial/introduction.html#strings)
    - [О Юникоде](https://python-all.ru/3.0/tutorial/introduction.html#about-unicode)
    - [Списки](https://python-all.ru/3.0/tutorial/introduction.html#lists)
  - [Первые шаги в программировании](https://python-all.ru/3.0/tutorial/introduction.html#first-steps-towards-programming)
- [Дополнительные средства управления потоком](https://python-all.ru/3.0/tutorial/controlflow.html)

  - [`if` инструкции](https://python-all.ru/3.0/tutorial/controlflow.html#if-statements)
  - [`for` инструкции](https://python-all.ru/3.0/tutorial/controlflow.html#for-statements)
  - [Функция `range()`](https://python-all.ru/3.0/tutorial/controlflow.html#the-range-function)
  - [`break` и `continue` инструкции, и `else` предложения в циклах](https://python-all.ru/3.0/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops)
  - [`pass` инструкции](https://python-all.ru/3.0/tutorial/controlflow.html#pass-statements)
  - [Определение функций](https://python-all.ru/3.0/tutorial/controlflow.html#defining-functions)
  - [Подробнее об определении функций](https://python-all.ru/3.0/tutorial/controlflow.html#more-on-defining-functions)

    - [Значения аргументов по умолчанию](https://python-all.ru/3.0/tutorial/controlflow.html#default-argument-values)
    - [Именованные аргументы](https://python-all.ru/3.0/tutorial/controlflow.html#keyword-arguments)
    - [Произвольные списки аргументов](https://python-all.ru/3.0/tutorial/controlflow.html#arbitrary-argument-lists)
    - [Распаковка списков аргументов](https://python-all.ru/3.0/tutorial/controlflow.html#unpacking-argument-lists)
    - [Лямбда-выражения](https://python-all.ru/3.0/tutorial/controlflow.html#lambda-forms)
    - [Строки документации](https://python-all.ru/3.0/tutorial/controlflow.html#documentation-strings)
  - [Интермеццо: Стиль кода](https://python-all.ru/3.0/tutorial/controlflow.html#intermezzo-coding-style)
- [Структуры данных](https://python-all.ru/3.0/tutorial/datastructures.html)

  - [Подробнее о списках](https://python-all.ru/3.0/tutorial/datastructures.html#more-on-lists)

    - [Использование списков в качестве стеков](https://python-all.ru/3.0/tutorial/datastructures.html#using-lists-as-stacks)
    - [Использование списков в качестве очередей](https://python-all.ru/3.0/tutorial/datastructures.html#using-lists-as-queues)
    - [Списковые включения](https://python-all.ru/3.0/tutorial/datastructures.html#list-comprehensions)
    - [Вложенные списковые включения](https://python-all.ru/3.0/tutorial/datastructures.html#nested-list-comprehensions)
  - [Инструкция `del`](https://python-all.ru/3.0/tutorial/datastructures.html#the-del-statement)
  - [Кортежи и последовательности](https://python-all.ru/3.0/tutorial/datastructures.html#tuples-and-sequences)
  - [Множества](https://python-all.ru/3.0/tutorial/datastructures.html#sets)
  - [Словари](https://python-all.ru/3.0/tutorial/datastructures.html#dictionaries)
  - [Приёмы работы с циклами](https://python-all.ru/3.0/tutorial/datastructures.html#looping-techniques)
  - [Подробнее об условиях](https://python-all.ru/3.0/tutorial/datastructures.html#more-on-conditions)
  - [Сравнение последовательностей и других типов](https://python-all.ru/3.0/tutorial/datastructures.html#comparing-sequences-and-other-types)
- [Модули](https://python-all.ru/3.0/tutorial/modules.html)

  - [Подробнее о модулях](https://python-all.ru/3.0/tutorial/modules.html#more-on-modules)

    - [Запуск модулей как скриптов](https://python-all.ru/3.0/tutorial/modules.html#executing-modules-as-scripts)
    - [Путь поиска модулей](https://python-all.ru/3.0/tutorial/modules.html#the-module-search-path)
    - [«Скомпилированные» файлы Python](https://python-all.ru/3.0/tutorial/modules.html#compiled-python-files)
  - [Стандартные модули](https://python-all.ru/3.0/tutorial/modules.html#standard-modules)
  - [Функция `dir()`](https://python-all.ru/3.0/tutorial/modules.html#the-dir-function)
  - [Пакеты](https://python-all.ru/3.0/tutorial/modules.html#packages)

    - [Импорт \* из пакета](https://python-all.ru/3.0/tutorial/modules.html#importing-from-a-package)
    - [Ссылки внутри пакета](https://python-all.ru/3.0/tutorial/modules.html#intra-package-references)
    - [Пакеты в нескольких каталогах](https://python-all.ru/3.0/tutorial/modules.html#packages-in-multiple-directories)
- [Ввод и вывод](https://python-all.ru/3.0/tutorial/inputoutput.html)

  - [Более изощрённое форматирование вывода](https://python-all.ru/3.0/tutorial/inputoutput.html#fancier-output-formatting)

    - [Старое форматирование строк](https://python-all.ru/3.0/tutorial/inputoutput.html#old-string-formatting)
  - [Чтение и запись файлов](https://python-all.ru/3.0/tutorial/inputoutput.html#reading-and-writing-files)

    - [Методы файловых объектов](https://python-all.ru/3.0/tutorial/inputoutput.html#methods-of-file-objects)
    - [Модуль `pickle`](https://python-all.ru/3.0/tutorial/inputoutput.html#the-pickle-module)
- [Ошибки и исключения](https://python-all.ru/3.0/tutorial/errors.html)

  - [Синтаксические ошибки](https://python-all.ru/3.0/tutorial/errors.html#syntax-errors)
  - [Исключения](https://python-all.ru/3.0/tutorial/errors.html#exceptions)
  - [Обработка исключений](https://python-all.ru/3.0/tutorial/errors.html#handling-exceptions)
  - [Возбуждение исключений](https://python-all.ru/3.0/tutorial/errors.html#raising-exceptions)
  - [Определяемые пользователем исключения](https://python-all.ru/3.0/tutorial/errors.html#user-defined-exceptions)
  - [Определение действий по очистке](https://python-all.ru/3.0/tutorial/errors.html#defining-clean-up-actions)
  - [Предопределённые действия по очистке](https://python-all.ru/3.0/tutorial/errors.html#predefined-clean-up-actions)
- [Классы](https://python-all.ru/3.0/tutorial/classes.html)

  - [Несколько слов о терминологии](https://python-all.ru/3.0/tutorial/classes.html#a-word-about-terminology)
  - [Области видимости и пространства имён в Python](https://python-all.ru/3.0/tutorial/classes.html#python-scopes-and-name-spaces)

    - [Пример областей видимости и пространств имён](https://python-all.ru/3.0/tutorial/classes.html#scopes-and-namespaces-example)
  - [Первое знакомство с классами](https://python-all.ru/3.0/tutorial/classes.html#a-first-look-at-classes)

    - [Синтаксис определения класса](https://python-all.ru/3.0/tutorial/classes.html#class-definition-syntax)
    - [Объекты классов](https://python-all.ru/3.0/tutorial/classes.html#class-objects)
    - [Объекты экземпляров](https://python-all.ru/3.0/tutorial/classes.html#instance-objects)
    - [Объекты методов](https://python-all.ru/3.0/tutorial/classes.html#method-objects)
  - [Разные замечания](https://python-all.ru/3.0/tutorial/classes.html#random-remarks)
  - [Наследование](https://python-all.ru/3.0/tutorial/classes.html#inheritance)

    - [Множественное наследование](https://python-all.ru/3.0/tutorial/classes.html#multiple-inheritance)
  - [Приватные переменные](https://python-all.ru/3.0/tutorial/classes.html#private-variables)
  - [Разное](https://python-all.ru/3.0/tutorial/classes.html#odds-and-ends)
  - [Исключения – это тоже классы](https://python-all.ru/3.0/tutorial/classes.html#exceptions-are-classes-too)
  - [Итераторы](https://python-all.ru/3.0/tutorial/classes.html#iterators)
  - [Генераторы](https://python-all.ru/3.0/tutorial/classes.html#generators)
  - [Генераторные выражения](https://python-all.ru/3.0/tutorial/classes.html#generator-expressions)
- [Краткий обзор стандартной библиотеки](https://python-all.ru/3.0/tutorial/stdlib.html)

  - [Интерфейс операционной системы](https://python-all.ru/3.0/tutorial/stdlib.html#operating-system-interface)
  - [Шаблоны имён файлов](https://python-all.ru/3.0/tutorial/stdlib.html#file-wildcards)
  - [Аргументы командной строки](https://python-all.ru/3.0/tutorial/stdlib.html#command-line-arguments)
  - [Перенаправление вывода ошибок и завершение программы](https://python-all.ru/3.0/tutorial/stdlib.html#error-output-redirection-and-program-termination)
  - [Поиск по шаблону в строках](https://python-all.ru/3.0/tutorial/stdlib.html#string-pattern-matching)
  - [Математика](https://python-all.ru/3.0/tutorial/stdlib.html#mathematics)
  - [Доступ к интернету](https://python-all.ru/3.0/tutorial/stdlib.html#internet-access)
  - [Даты и время](https://python-all.ru/3.0/tutorial/stdlib.html#dates-and-times)
  - [Сжатие данных](https://python-all.ru/3.0/tutorial/stdlib.html#data-compression)
  - [Измерение производительности](https://python-all.ru/3.0/tutorial/stdlib.html#performance-measurement)
  - [Контроль качества](https://python-all.ru/3.0/tutorial/stdlib.html#quality-control)
  - [Батарейки в комплекте](https://python-all.ru/3.0/tutorial/stdlib.html#batteries-included)
- [Краткий обзор стандартной библиотеки – часть II](https://python-all.ru/3.0/tutorial/stdlib2.html)

  - [Форматирование вывода](https://python-all.ru/3.0/tutorial/stdlib2.html#output-formatting)
  - [Шаблоны](https://python-all.ru/3.0/tutorial/stdlib2.html#templating)
  - [Работа с двоичными данными: структуры записей](https://python-all.ru/3.0/tutorial/stdlib2.html#working-with-binary-data-record-layouts)
  - [Многопоточность](https://python-all.ru/3.0/tutorial/stdlib2.html#multi-threading)
  - [Логирование](https://python-all.ru/3.0/tutorial/stdlib2.html#logging)
  - [Слабые ссылки](https://python-all.ru/3.0/tutorial/stdlib2.html#weak-references)
  - [Инструменты для работы со списками](https://python-all.ru/3.0/tutorial/stdlib2.html#tools-for-working-with-lists)
  - [Арифметика с плавающей запятой десятичных чисел](https://python-all.ru/3.0/tutorial/stdlib2.html#decimal-floating-point-arithmetic)
- [Что дальше?](https://python-all.ru/3.0/tutorial/whatnow.html)
- [Интерактивное редактирование ввода и подстановка истории](https://python-all.ru/3.0/tutorial/interactive.html)

  - [Редактирование строки](https://python-all.ru/3.0/tutorial/interactive.html#line-editing)
  - [Подстановка истории](https://python-all.ru/3.0/tutorial/interactive.html#history-substitution)
  - [Привязки клавиш](https://python-all.ru/3.0/tutorial/interactive.html#key-bindings)
  - [Комментарии](https://python-all.ru/3.0/tutorial/interactive.html#commentary)
- [Арифметика с плавающей запятой: проблемы и ограничения](https://python-all.ru/3.0/tutorial/floatingpoint.html)

  - [Ошибка представления](https://python-all.ru/3.0/tutorial/floatingpoint.html#representation-error)
