Если 'port' нет в config, устанавливаем его значение по умолчанию:
if 'port' not in config: config['port'] = 80 port = config['port']
Но можно сделать это более элегантно с помощью setdefault:
port = config.setdefault('port', 80)
Метод setdefault устанавливает новое значение, если оно ещё не задано, и возвращает сохранённое значение вне зависимости от того, было ли оно изменено:
In : config = {} In : config.setdefault('port', 80) Out: 80 In : config.setdefault('port', 443) Out: 80
Если 'port' нет в config, устанавливаем его значение по умолчанию:
if 'port' not in config: config['port'] = 80 port = config['port']
Но можно сделать это более элегантно с помощью setdefault:
port = config.setdefault('port', 80)
Метод setdefault устанавливает новое значение, если оно ещё не задано, и возвращает сохранённое значение вне зависимости от того, было ли оно изменено:
In : config = {} In : config.setdefault('port', 80) Out: 80 In : config.setdefault('port', 443) Out: 80
For some time, Mr. Durov and a few dozen staffers had no fixed headquarters, but rather traveled the world, setting up shop in one city after another, he told the Journal in 2016. The company now has its operational base in Dubai, though it says it doesn’t keep servers there.Mr. Durov maintains a yearslong friendship from his VK days with actor and tech investor Jared Leto, with whom he shares an ascetic lifestyle that eschews meat and alcohol.
To pay the bills, Mr. Durov is issuing investors $1 billion to $1.5 billion of company debt, with the promise of discounted equity if the company eventually goes public, the people briefed on the plans said. He has also announced plans to start selling ads in public Telegram channels as soon as later this year, as well as offering other premium services for businesses and users.