Обложка канала

Библиотека Python разработчика

20835 @BookPython

Библиотека Python разработчика. Книги по программированию на Python.

Библиотека Python разработчика

4 года назад
Открыть в
In Python, a variable name may consist of a single underscore: _. Though usually such names are not descriptive enough and should not be used, there are at least three cases when _ has a conventional meaning. First, interactive Python interpreters use _ to store the result of the last executed expression: >>> 2 + 2 4 >>> _ 4 Second, the gettext module's manual recommends to alias its gettext() function to _() as a way to minimize cluttering your code. Third, _ is used when you have to come up with names for values you don't' care about: >>> log_entry = '10:50:24 14234 GET /api/v1/test' >>> time, _, method, location = log_entry.split() @BookPython