TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

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

Резултати

Пронајдени 24 слични објави

Пребарај: #uel

当前筛选 #uel清除筛选
Football Daily News

@FootyNews · Post #112806 · 18.05.2023 г., 22:09

Sevilla have won 100% of the #UEL semi-finals they've contested: ◉ 2005/06 v Schalke ◉ 2006/07 v Osasuna ◉ 2013/14 v Valencia ◉ 2014/15 v Fiorentina ◉ 2015/16 v Shaktar ◉ 2019/20 v Man Utd ◉ 2022/23 v Juventus And they've gone on to lift the trophy every single time. 🤯https://t.co/QoHm1XFxnh

Hashtags

Football Daily News

@FootyNews · Post #112798 · 18.05.2023 г., 19:09

RT @Squawka_Live: 19-year-old England U20 international Samuel Iling-Junior starts for Juventus for only the third time. Thrown in at the deep end. 🤿 #UELhttps://t.co/m5XW1Rx6Cihttps://t.co/bBFN7rfQGO

Hashtags

Football Daily News

@FootyNews · Post #112594 · 11.05.2023 г., 20:09

RT @Squawka_Live: Lucas Ocampos first-half by numbers vs Juventus: 100% passing accuracy 100% dribbles completed 6 touches in opp. box (most) 5 shots (most) 5 duels won (Sevilla most) 2 chances created (joint-most) 1 assist 0.73 xG Posting FT stats at HT. 🥶 #UELhttps://t.co/0SXs7yyirm

Hashtags

Football Daily News

@FootyNews · Post #112593 · 11.05.2023 г., 19:10

RT @Squawka_Live: Juventus' record at home in the Europa League since 2009: 🤝 0-0 ✅ 3-1 ✅ 1-0 ✅ 1-0 🤝 3-3 🤝 1-1 🤝 0-0 ✅ 2-0 🤝 1-1 ✅ 2-1 🤝 0-0 🤝 1-1 ✅ 1-0 ✅ 1-0 Mission impossible for Sevilla? #UELhttps://t.co/ulnbRPSOGg

Hashtags

Football Daily News

@FootyNews · Post #111952 · 20.04.2023 г., 22:09

RT @Squawka_Live: Paulo Dybala's game by numbers vs Feyenoord: 47 minutes played 38 touches 6 shots 3 duels won 3 chances created 3 shots on target 1 goal 0.31xG Impact. 💥#UELhttps://t.co/awnOgtSlY4

Hashtags

Football Daily News

@FootyNews · Post #111949 · 20.04.2023 г., 22:09

RT @Squawka_Live: No Premier League player has made more errors leading to a goal across all competitions than David De Gea since the start of last season (5). 😬#UELhttps://t.co/4g3ld0CKW4

Hashtags

Football Daily News

@FootyNews · Post #111945 · 20.04.2023 г., 21:10

RT @Squawka_Live: Man Utd in the first leg vs Sevilla: ◉ Score two own goals Man Utd in the second leg vs. Sevilla: ◉ Commit two errors leading to goals Shooting themselves in the foot. 🔫#UELhttps://t.co/Bv4VnTGCbl

Hashtags

Football Daily News

@FootyNews · Post #111943 · 20.04.2023 г., 20:09

RT @Squawka_Live: Erik Lamela created more chances than any other player in the first half vs. Man Utd (3). He also provided the assist for Youssef En-Nesyri, his first for Sevilla this season. 🅰️#UELhttps://t.co/baxztemlkr

Hashtags

Football Daily News

@FootyNews · Post #111941 · 20.04.2023 г., 18:09

RT @Squawka_Live: Sevilla XI: Bono; Navas, Bade, Marcao, Acuna; Gudelj, Fernando; Ocampos, Rakitic, Lamela; En-Nesyri. Man Utd XI: De Gea; Wan-Bissaka, Maguire, Lindelof, Dalot; Eriksen, Casemiro, Sabitzer; Antony, Martial, Sancho. #UEL

Hashtags

12
ПретходнаСтраница 1 од 2Следна