Ранее я уже упоминал о другой фишке из ˍˍfutureˍˍ , это оператор деления.
from __future__ import division
Суть проста. Раньше сложность типа данных результата поределялась типом самого сложного операнда.
Например:
int/int => int
int/float => float
В первом случае оба операнда int, значит и результат будет int. Во втором float более сложный тип, поэтому результат будет float.
Если нам требуется получить дробное значение при делении двух int то приходилось форсированно один из операндов конверировать в float.
12/float(5) => float
Но с новой "философией" это не требуется. В Python3 "floor division" заменили на "true division" а старый способ теперь работает через оператор "//".
>>> 3/2
1.5
>>> 3//2
1
То есть теперь деление int на int даёт float если результат не целое число.
В классах теперь доступны методы __floordiv__() и __truediv__() для определения поведения с этими операторами.
Данный переход описан в PEP238.
#pep#2to3#basic
📍 Mount Teide, Tenerife Island, Spain 🇪🇸
🌋 Mount Teide is located in the center of the largest of the Canary Islands - Tenerife. The mountain, which can be seen today from any point on the island of Tenerife, grew more than a hundred thousand years ago from the depths of the ancient stratovolcano Las Cañadas, the top of which once collapsed inward under the weight of the erupting lava.
This majestic peak, standing at 3,718 meters (12,198 feet), is the highest point in Spain and the third highest volcano in the world, rising from its base on the ocean floor. The surrounding Teide National Park boasts an otherworldly landscape of volcanic craters, lava fields, and unique flora and fauna. A cable car ride to the top offers breathtaking views of the island and the Atlantic Ocean beyond. 🌋🚠
#travel#adventure#canaryislands
🇪🇸🇮🇨Spain says over 1,000 migrants reached its Canary Islands in 3 days as more attempt deadly crossing
More than 1,000 migrants from sub-Saharan countries arrived in Spain's Canary Islands in 18 boats over the past three days, Spain's marine rescue service said on Monday.
The archipelago off northwest Africa has seen a surge in migrant arrivals in recent weeks as more people from West Africa attempt to get their, which is a dangerous trip.
Officials say 7,270 migrants arrived in January, about as many as in the first six months of 2023.
Most of the boats depart from Mauritania. Spanish Prime Minister Pedro Sánchez and European Commission President Ursula von der Leyen will visit the West African country on Thursday to encourage authorities to try to curtail the departures.
#Spain#CanaryIslands
@africaintel
Drone drops food for dogs trapped in La Palma by volcano lava
Several emaciated dogs lie curled up in and around a walled, ash-covered yard cut off by volcanic lava in the mountainous area of Todoque, on the Spanish island of La Palma, until a drone appears in the sky to drop packages with food and water.
#CanaryIslands#LaPalma#volcano#Spain#News#Reuters
Subscribe: http://smarturl.it/reuterssubscribe
Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled.
Get the latest news on: http://reuters.com/
Follow Reuters on Facebook: https://www.facebook.com/Reuters
Follow Reuters on Twitter: https://twitter.com/Reuters
Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en
➖@reutersworldchannel➖
Sunspots seen in Spain as geomagnetic storm expected
Sunspots were seen from Spain's Canary Islands as a geomagnetic storm was expected to reach the Earth.
#Sunspots#Spain#CanaryIslands#GeomagneticStorm#News#Reuters
Subscribe: http://smarturl.it/reuterssubscribe
Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled.
Get the latest news on: http://reuters.com/
Follow Reuters on Facebook: https://www.facebook.com/Reuters
Follow Reuters on Twitter: https://twitter.com/Reuters
Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en
➖@reutersworldchannel➖
Red-hot lava forces evacuations in Spain's La Palma
Over 700 residents on the Spanish island of La Palma were ordered to abandon their homes as lava advanced toward their neighborhoods.
#LaPalma#Spain#volcano#CanaryIslands#CumbreVieja#News#Reuters
Subscribe: http://smarturl.it/reuterssubscribe
Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled.
Get the latest news on: http://reuters.com/
Follow Reuters on Facebook: https://www.facebook.com/Reuters
Follow Reuters on Twitter: https://twitter.com/Reuters
Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en
➖@reutersworldchannel➖
🐟 Rare Encounter with the “Sea Devil” near the Canary Islands!
For the first time in history, biologists managed to capture this mysterious deep-sea predator on video. Usually, only larvae or dead specimens are observed, as anglerfish live at extreme depths where almost no light reaches. But this time, the fish rose to the surface and appeared in front of the researchers’ camera — a truly unique observation for science!
#MarineLife#Anglerfish#DeepSeaMysteries#CanaryIslands☘️Read the latest environmental news on the @ekologuz page. Follow us and send your suggestions and wishes via @eklguz_bot
Instagram | Facebook | Twitter | Sayt | Youtube.
Lava spews from La Palma volcano
The Cumbre Vieja volcano on Spain's La Palma island continues to spew lava and smoke.
#Volcano#LaPalma#Spain#Lava#CanaryIslands#CumbreVieja#News#Reuters
Subscribe: http://smarturl.it/reuterssubscribe
Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled.
Get the latest news on: http://reuters.com/
Follow Reuters on Facebook: https://www.facebook.com/Reuters
Follow Reuters on Twitter: https://twitter.com/Reuters
Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en
➖@reutersworldchannel➖
Volunteers take in La Palma's homeless pets
This makeshift shelter in La Palma, Spain, is housing hundreds of homeless pets after their owners were forced to flee from the Cumbre Vieja volcano.
#Volcano#LaPalma#Spain#Lava#CanaryIslands#CumbreVieja#HomelessPets#Pets#News#Reuters
Subscribe: http://smarturl.it/reuterssubscribe
Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled.
Get the latest news on: http://reuters.com/
Follow Reuters on Facebook: https://www.facebook.com/Reuters
Follow Reuters on Twitter: https://twitter.com/Reuters
Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en
➖@reutersworldchannel➖