@sgmrt · Post #2308 · 04.04.2025 г., 08:09
[EWL] UPDATE: Normal train services are progressively being restored. Free regular bus is available between #Queenstown and #BoonLay. - 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
Пребарај: #boonlay
@sgmrt · Post #2308 · 04.04.2025 г., 08:09
[EWL] UPDATE: Normal train services are progressively being restored. Free regular bus is available between #Queenstown and #BoonLay. - SMRT
Hashtags
@sgmrt · Post #2305 · 04.04.2025 г., 07:59
[EWL] UPDATE: Train services are progressively being restored. Free regular bus is available between #Queenstown and #BoonLay. - SMRT
Hashtags
@sgmrt · Post #2059 · 25.09.2024 г., 09:59
[EWL]:UPDATE Due to a power fault, there is no train svc between Jurong East and Buona Vista. Free regular bus & bridging bus services is still available between #BoonLay and #Queenstown. - SMRT
Hashtags
@sgmrt · Post #2046 · 25.09.2024 г., 07:29
[EWL]:UPDATE Due to a power fault, there is no train svc between #BoonLay and #Queenstown. Free regular bus & bridging bus services is still available between #BoonLay and #Queenstown. - SMRT
Hashtags
@sgmrt · Post #2043 · 25.09.2024 г., 06:44
[EWL]:UPDATE Free regular bus & bridging bus services are still available between #BoonLay and #Queenstown. Passengers with special needs, please approach our station staff for assistance. Our staff are attending to the matter. - SMRT
Hashtags
@sgmrt · Post #2042 · 25.09.2024 г., 06:29
[EWL]:UPDATE Due to a power fault, there is no train svc between #BoonLay and #Queenstown. We encourage fellow commuters to look out for persons with special needs. Please lend a helping hand and approach our station staff if you need further assistance. - SMRT
Hashtags
@sgmrt · Post #2035 · 25.09.2024 г., 04:44
[EWL]:UPDATE Free regular bus & bridging bus services are still available between #BoonLay and #Queenstown. Passengers with special needs, please approach our station staff for assistance. We are working to recover service. - SMRT
Hashtags
@sgmrt · Post #2034 · 25.09.2024 г., 04:24
[EWL]:UPDATE Due to a power fault, there is no train service between #BoonLay and #Queenstown. Free regular bus & bridging bus services are still available between #BoonLay and #Queenstown. We apologies for the inconvenience caused. - SMRT
Hashtags
@sgmrt · Post #2030 · 25.09.2024 г., 03:49
[EWL]:UPDATE Free regular bus & bridging bus services are still available between #BoonLay and #Queenstown. Passengers with special needs, please approach our station staff for assistance. We apologies to affect your commute. - SMRT
Hashtags
@sgmrt · Post #2019 · 25.09.2024 г., 02:09
[EWL]: Due to a power fault, there is no train service between #BoonLay and #Queenstown.Free regular bus & bridging bus services are available between #BoonLay and #Queenstown. - SMRT
Hashtags
@sgmrt · Post #2422 · 06.08.2025 г., 03:14
[EWL] CLEARED: Train services from #BoonLay to #BuonaVista have resumed. Free regular bus & free bridging bus services have ended. We apologise for affecting your commute. - SMRT
Hashtags
@sgmrt · Post #2420 · 06.08.2025 г., 00:39
[EWL] UPDATE: We continue to provide free regular bus and bridging bus services between #BoonLay and #BuonaVista station. - SMRT
Hashtags