@sgmrt · Post #2279 · 05.03.2025 г., 09:04
[CCL]: Train services have resumed to normalcy. Free regular bus services will cease between #Promenade and #Serangoon. We are sorry for affecting your commute. - 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
Пребарај: #serangoon
@sgmrt · Post #2279 · 05.03.2025 г., 09:04
[CCL]: Train services have resumed to normalcy. Free regular bus services will cease between #Promenade and #Serangoon. We are sorry for affecting your commute. - SMRT
Hashtags
@sgmrt · Post #2274 · 05.03.2025 г., 08:14
[CCL]: Please add 30 mins train travel time between #Promenade and #Serangoon, in both directions due to train fault. Free regular bus service is available between #Promenade and #Serangoon. Train service is still available. - SMRT
Hashtags
@sgmrt · Post #2181 · 14.12.2024 г., 11:14
[CCL] UPDATE: Train fault cleared. Train service between #Promenade and #Serangoon is progressively returning to normal. Free regular bus service are still available between #Promenade and #Serangoon. - SMRT
Hashtags
@sgmrt · Post #2180 · 14.12.2024 г., 11:05
[CCL] UPDATE: Please add an additional 30mins train travel time between #Promenade and #Serangoon due to a train fault. Free regular bus service are available between #Promenade and #Serangoon. - SMRT
Hashtags
@sgmrt · Post #2179 · 14.12.2024 г., 10:49
[CCL] UPDATE: Additional 30mins train travel time between #Promenade and #Serangoon due to a train fault. Free regular bus service are available between #Promenade and #Serangoon. - SMRT
Hashtags
@sgmrt · Post #1424 · 01.04.2022 г., 04:26
[CCL] CLEARED: Fault cleared, trains service progressively resuming. Free regular bus and bridging bus services between #Promenade and #Serangoon are still available. - SMRT
Hashtags
@sgmrt · Post #2352 · 20.05.2025 г., 00:44
[CCL] UPDATE: Train fault has recovered, train services are progressively resuming. Free regular bus services are still available between #Serangoon and #BuonaVista. - SMRT
Hashtags
@sgmrt · Post #2351 · 20.05.2025 г., 00:39
[CCL] UPDATE: Please continue to add 30min travel time between #PayaLebar and #BuonaVista. Free regular bus services are available between #Serangoon and #BuonaVista - SMRT
Hashtags
@sgmrt · Post #2350 · 20.05.2025 г., 00:34
[CCL]: Due to a train fault, please add 30 minutes travel time between #PayaLebar and #BuonaVista. Free regular bus services are available between #Serangoon and #BuonaVista. https://bit.ly/44HtD1b - SMRT
Hashtags
@sgmrt · Post #1422 · 01.04.2022 г., 04:09
[CCL] UPDATE: Additional 30mins train travel time between #Stadium and #Bartley due to a train fault. Free regular bus and bridging bus services between #Promenade and #Serangoon are available. - SMRT
@sgmrt · Post #1420 · 01.04.2022 г., 03:52
[CCL] Additional 20mins train travel time between #Stadium and #Bartley due to a train fault. Free regular bus services between #Promenade and #Serangoon are available. - SMRT
@sgmrt · Post #2278 · 05.03.2025 г., 08:54
[CCL]: Train services are progressively returning to normalcy. Please add 5 mins of additional travelling time between #Promenade and #Serangoon in both directions. Free regular bus services are available between #Promenade and #Serangoon. Shuttle train service will cease between #Bartley and #Mountbatten. - SMRT