@sgmrt · Post #1567 · 14.12.2022 г., 04:29
[EWL] UPDATE: Train svc btwn #GulCircle and #Lakeside have resumed. Free regular bus and free bridging bus btwn #GulCircle and #Lakeside have ceased. - SMRT
Hashtags
TGINSIGHT SIMILAR POSTS
Изворен канал @pythonotes · Post #156 · 2 окт.
Те, кто в Python не первый день, хорошо знают, что на число можно умножить не только число, но и другие типы. Главное, чтобы у этих типов была реализация такой операции. # list >>> [1] * 3 [1, 1, 1] # tuple >>> (2, 3) * 3 (2, 3, 2, 3, 2, 3) # string >>> "A" * 3 "AAA" Так работает полиморфизм стандартных типов. Интересно здесь то, что это сработает и в том случае, когда порядок операндов обратный. То есть int умножить на [тип]. # list >>> 3 * [1] [1, 1, 1] # tuple >>> 3 * (2, 3) (2, 3, 2, 3, 2, 3) # string >>> 3 * "A" "AAA" Если хотите реализовать такое поведение в ваших классах то следует помнить два момента: 1. Если множитель справа, то вам нужно реализовать метод __mul__, наш класс это первый операнд, то есть слева. myType * 3 2. Если множитель слева, то вам нужно реализовать метод __rmul__, наш класс это второй операнд, справа. 3* myType Всё тоже самое можно делать и для других математических операторов. И если в этом примере действие и результат будут фактически одинаковыми, то бывают ситуации, когда это не так. Например, при умножении матриц имеет значение порядок операндов. Для других операторов, таких как деление или сдвиг, очень важно кто с какой стороны находится. >>> 2/4, 4/2 (0.5, 2.0) >>> 2<<3, 3<<2 (16, 12) >>> 100%15, 15%100 (10, 15) #tricks#basic
Пребарај: #lakeside
@sgmrt · Post #1567 · 14.12.2022 г., 04:29
[EWL] UPDATE: Train svc btwn #GulCircle and #Lakeside have resumed. Free regular bus and free bridging bus btwn #GulCircle and #Lakeside have ceased. - SMRT
Hashtags
@sgmrt · Post #1566 · 14.12.2022 г., 04:15
[EWL] UPDATE: Train svc btwn #GulCircle and #Lakeside have resumed. Free regular bus & free bridging bus is still available btwn #GulCircle and #Lakeside. - SMRT
Hashtags
@sgmrt · Post #1565 · 14.12.2022 г., 04:15
[EWL] UPDATE: Train svc btwn #GulCircle and #Lakeside have resumed. Free regular bus is still available btwn #GulCircle and #Lakeside. Free bridging bus ceased. - SMRT
Hashtags
@sgmrt · Post #1564 · 14.12.2022 г., 03:32
[EWL]: Due to a signalling fault, there is no train svc btwn #GulCircle and #Lakeside. Free regular bus and free bus bridging is available btwn #GulCircle and #Lakeside. - SMRT
Hashtags
@sgmrt · Post #2304 · 04.04.2025 г., 07:39
[EWL] UPDATE: Due to a track fault, please expect an additional 20 mins of travelling time between #Queenstown and #BoonLay. Shuttle train is available between #JurongEast and #Lakeside. Please look out for fellow commuters in need and give a helping hand. We apologise for - SMRT
@sgmrt · Post #2303 · 04.04.2025 г., 07:39
[EWL] UPDATE: Due to a track fault, please expect an additional 20 mins of travelling time between #Queenstown and #BoonLay. Shuttle train is available between #JurongEast and #Lakeside. Please look out for fellow commuters in need and give a helping hand. We apologise for https://bit.ly/3Rz4KwF - SMRT
@sgmrt · Post #2299 · 04.04.2025 г., 06:54
[EWL] UPDATE: Due to a track fault, please expect an additional 20mins of travelling time between #Queenstown and #BoonLay. Shuttle train is available between #JurongEast and #Lakeside. Free regular bus is available between #BuonaVista and #BoonLay. If you have any enquiries, - SMRT
@sgmrt · Post #2297 · 04.04.2025 г., 06:24
[EWL] UPDATE: Due to a track fault, please expect an additional 20mins of travelling time between #Queenstown and #BoonLay. Shuttle train is available between #JurongEast and #Lakeside. Free regular bus is available between #BuonaVista and #BoonLay. Train service is still - SMRT
@sgmrt · Post #2294 · 04.04.2025 г., 05:39
[EWL]: Due to a track fault, please expect an additional 20mins of travelling time between #Queenstown and #BoonLay. Shuttle train is available between #JurongEast and #Lakeside. Free regular bus is available between #BuonaVista and #BoonLay. - SMRT
@sgmrt · Post #2293 · 04.04.2025 г., 05:34
[EWL]: Due to a track fault, please expect an additional 20mins of travelling time between #Queenstown and #BoonLay. Shuttle train are available between #Clementi and #JurongEast and #JurongEast and #Lakeside. Free regular bus is available between #BuonaVista and #BoonLay. - SMRT