PYTHON_JOB_INTERVIEW Telegram 1182
This media is not supported in your browser
VIEW IN TELEGRAM
🖥 Нужно временно отключить все принты — например, в проде или при юнит-тестах?

Этот трюк нужен, чтобы временно отключить принты не удаляя и не комментируя строки вручную.

На экране простой способ сделать это через контекстный менеджер — без сторонних библиотек и без комментирования строк.


import sys, os
from contextlib import contextmanager

@contextmanager
def suppress_print():
saved = sys.stdout
sys.stdout = open(os.devnull, 'w')
yield
sys.stdout.close()
sys.stdout = saved

Пример:

print("Это видно")
with suppress_print():
print("А это — нет")
print("Снова видно")


@python_job_interview - вопросы с собеседований Python
Please open Telegram to view this post
VIEW IN TELEGRAM
🔥11🥰42



tgoop.com/python_job_interview/1182
Create:
Last Update:

🖥 Нужно временно отключить все принты — например, в проде или при юнит-тестах?

Этот трюк нужен, чтобы временно отключить принты не удаляя и не комментируя строки вручную.

На экране простой способ сделать это через контекстный менеджер — без сторонних библиотек и без комментирования строк.


import sys, os
from contextlib import contextmanager

@contextmanager
def suppress_print():
saved = sys.stdout
sys.stdout = open(os.devnull, 'w')
yield
sys.stdout.close()
sys.stdout = saved

Пример:

print("Это видно")
with suppress_print():
print("А это — нет")
print("Снова видно")


@python_job_interview - вопросы с собеседований Python

BY Python вопросы с собеседований


Share with your friend now:
tgoop.com/python_job_interview/1182

View MORE
Open in Telegram


Telegram News

Date: |

In handing down the sentence yesterday, deputy judge Peter Hui Shiu-keung of the district court said that even if Ng did not post the messages, he cannot shirk responsibility as the owner and administrator of such a big group for allowing these messages that incite illegal behaviors to exist. Judge Hui described Ng as inciting others to “commit a massacre” with three posts teaching people to make “toxic chlorine gas bombs,” target police stations, police quarters and the city’s metro stations. This offence was “rather serious,” the court said. How to Create a Private or Public Channel on Telegram? Deputy District Judge Peter Hui sentenced computer technician Ng Man-ho on Thursday, a month after the 27-year-old, who ran a Telegram group called SUCK Channel, was found guilty of seven charges of conspiring to incite others to commit illegal acts during the 2019 extradition bill protests and subsequent months. The visual aspect of channels is very critical. In fact, design is the first thing that a potential subscriber pays attention to, even though unconsciously.
from us


Telegram Python вопросы с собеседований
FROM American