Ранее я уже упоминал о другой фишке из ˍˍ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
Stract is an open source search engine where the user has the ability to see exactly what is going on and customize almost everything about their search results. It's a search engine made for hackers and tinkerers just like ourselves. No more searches where some of the terms in the query arent used, and the engine tries to guess what you really meant. You get what you search for.
https://stract.com
https://github.com/StractOrg/stract
#Web#Search#SearchEngine
#FLOSS
SimpleX Chat: private and secure cross platform messenger without any user IDs (not even random)
:~ E2E-encrypted messages with markdown and editing
:~ E2E-encrypted images and files
:~ Decentralized secret groups — only users know they exist
:~ E2E-encrypted voice messages
:~ Disappearing messages
:~ E2E-encrypted audio and video calls
:~ Portable encrypted database — move your profile to another device
:~Incognito mode —
unique to SimpleX Chat
Website : https://simplex.chat/
SimpleX Chat (SimpleX Chat - e2e encrypted messenger without any user IDs - private by design!)
https://f-droid.org/packages/chat.simplex.app/
Quick start – https://simplex.chat/docs/guide/readme.html
#SimpleXchat#security#privacy#encryption#E2EE
#FLOSS
NAPS2 - Scan #documents to PDF and more – https://www.naps2.com/
NAPS2 is free and open source scanning software for Windows, Mac and Linux.
Easily scan with devices from Canon, Brother, HP, Epson, Fujitsu, and more. Then save to #PDF, #TIFF, #JPEG, or #PNG with a single click.
#Scan#Floss
#cplusplus#apple_silicon#bsd#c_plus_plus#cmake#floss#game#gplv2#json#linux#lua#macos_app#python#strategy#windows
Widelands is a free, open-source real-time strategy game like Settlers II, where you lead a small clan to build roads, gather resources like wood and gold, manage four unique tribes, trade, or fight in single-player campaigns and multiplayer. Download it easily for Windows, Mac, or Linux, or compile from source with simple scripts and tools like CMake on various systems. This lets you enjoy deep, replayable empire-building fun at no cost, anytime with friends or AI.
https://github.com/widelands/widelands