QUIZ_PYTHON Telegram 3607
Вы можете использовать словари и другие структуры данных в Python для построения более универсальных разновидностей таблиц действий. Вот пример:

key = 'got'
{'already': (lambda: 2 + 2), 'got': (lambda: 2 * 4), 'one': (lambda: 2 ** 6)}[key]()

Когда Python создает временный словарь, каждое вложенное выражение lambda генерирует и оставляет после себя функцию, подлежащую вызову в будущем. Индексация по ключу извлекает одну из функций, а круглые скобки приводят к вызову извлеченной функции. При такой реализации словарь становится более универсальным инструментом для множественного ветвления, нежели оператор if.



tgoop.com/quiz_python/3607
Create:
Last Update:

Вы можете использовать словари и другие структуры данных в Python для построения более универсальных разновидностей таблиц действий. Вот пример:

key = 'got'
{'already': (lambda: 2 + 2), 'got': (lambda: 2 * 4), 'one': (lambda: 2 ** 6)}[key]()

Когда Python создает временный словарь, каждое вложенное выражение lambda генерирует и оставляет после себя функцию, подлежащую вызову в будущем. Индексация по ключу извлекает одну из функций, а круглые скобки приводят к вызову извлеченной функции. При такой реализации словарь становится более универсальным инструментом для множественного ветвления, нежели оператор if.

BY Python: задачки и вопросы


Share with your friend now:
tgoop.com/quiz_python/3607

View MORE
Open in Telegram


Telegram News

Date: |

But a Telegram statement also said: "Any requests related to political censorship or limiting human rights such as the rights to free speech or assembly are not and will not be considered." As the broader market downturn continues, yelling online has become the crypto trader’s latest coping mechanism after the rise of Goblintown Ethereum NFTs at the end of May and beginning of June, where holders made incoherent groaning sounds and role-played as urine-loving goblin creatures in late-night Twitter Spaces. The administrator of a telegram group, "Suck Channel," was sentenced to six years and six months in prison for seven counts of incitement yesterday. Joined by Telegram's representative in Brazil, Alan Campos, Perekopsky noted the platform was unable to cater to some of the TSE requests due to the company's operational setup. But Perekopsky added that these requests could be studied for future implementation. As of Thursday, the SUCK Channel had 34,146 subscribers, with only one message dated August 28, 2020. It was an announcement stating that police had removed all posts on the channel because its content “contravenes the laws of Hong Kong.”
from us


Telegram Python: задачки и вопросы
FROM American