Explicit Conversion Flag
Флаг явного преобразования используется для преобразования значения поля format перед его непосредственным форматированием.
Это поле можно использовать для переопределения поведения format для какого либо конкретного типа и форматирования значения. В настоящее время распространены два явных флага преобразования:
!r – преобразует значение в строку, используя функцию repr()
!s – преобразует значение в строку, используя функцию str()
В примере, в случае с флагом !r строка 'Hello' будет напечатана с кавычками в поле шириной не менее 20 символов, а в случае с флагом !s – без кавычек (в более удобном для чтения виде).
#repr#str#format
[Reddit] How is NonZeroU32 different than a newtype?
Looking at the source for std::num::NonZeroU32 shows that it's defined as
#repr(transparent)
pub struct NonZeroU32(u32);
and the get method is just an inline self.0. Why, then, does the compiler treat them differently?
https://www.python.org/dev/peps/pep-0498/
#Interpolation
# Python supports multiple ways to format text strings.
# These include %-formatting,
# str.format(),
# and string.Template
# The !s, !r, and !a conversions are not strictly required.
# Because arbitrary expressions are allowed inside the #f_strings,
# this code:
»> a = 'some string'
»> f'{a!r}'
"'some string'"
Is identical to:
»> f'{repr(a)}'
"'some string'"
Similarly, !s can be replaced by calls to #str() and !a by calls to #ascii().
@YouTubeReaderBot
Qué puede hacer este bot?
Este bot es un lector de YouTube, te permite suscribirte a los canales de Youtube.
Idioma: Inglés, Ruso
(visto en @BotsGram_cu)
#youtube, #subscribe, #channel, #video, #notification, #rss, #format, #url, #link, #group, #telegram, #remind