Может показаться, что ответ = 1, т.к. hash любого инстанса класса Some равен 1.
1) При добавлении нового элемента в set, dict питон находит его hash(element) (если вы не знаете, что такое хэш функция и зачем она нужна, почитайте про хэш таблицы).
2) Из этого хэша определяется индекс в массиве, куда нужно вставить этот элемент.
3) Если по этому индексу ничего нет, то элемент просто вставляется.
4) А если там уже есть какой-то элемент (это коллизия), то питон уже сравнивает существуещий элемент с тем, который хотим добавить (new == old). Если они равны, то старый заменяется новым элементом.
5) В нашем случае все экземпляры Some разные, т.к.
Может показаться, что ответ = 1, т.к. hash любого инстанса класса Some равен 1.
1) При добавлении нового элемента в set, dict питон находит его hash(element) (если вы не знаете, что такое хэш функция и зачем она нужна, почитайте про хэш таблицы).
2) Из этого хэша определяется индекс в массиве, куда нужно вставить этот элемент.
3) Если по этому индексу ничего нет, то элемент просто вставляется.
4) А если там уже есть какой-то элемент (это коллизия), то питон уже сравнивает существуещий элемент с тем, который хотим добавить (new == old). Если они равны, то старый заменяется новым элементом.
5) В нашем случае все экземпляры Some разные, т.к.
__eq__ всегда возвращает False
Поэтому ответ 5.
#set #dict #hash
BY PyThrone
Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283
Telegram today rolling out an update which brings with it several new features.The update also adds interactive emoji. When you send one of the select animated emoji in chat, you can now tap on it to initiate a full screen animation. The update also adds interactive emoji. When you send one of the select animated emoji in chat, you can now tap on it to initiate a full screen animation. This is then visible to you or anyone else who's also present in chat at the moment. The animations are also accompanied by vibrations. This is then visible to you or anyone else who's also present in chat at the moment. The animations are also accompanied by vibrations.
Export WhatsApp stickers to Telegram on iPhone
You can’t. What you can do, though, is use WhatsApp’s and Telegram’s web platforms to transfer stickers. It’s easy, but might take a while.Open WhatsApp in your browser, find a sticker you like in a chat, and right-click on it to save it as an image. The file won’t be a picture, though—it’s a webpage and will have a .webp extension. Don’t be scared, this is the way. Repeat this step to save as many stickers as you want.Then, open Telegram in your browser and go into your Saved messages chat. Just as you’d share a file with a friend, click the Share file button on the bottom left of the chat window (it looks like a dog-eared paper), and select the .webp files you downloaded. Click Open and you’ll see your stickers in your Saved messages chat. This is now your sticker depository. To use them, forward them as you would a message from one chat to the other: by clicking or long-pressing on the sticker, and then choosing Forward.