Package: totemp
ToTempToTempis a temperature conversion package with Celsius, Delisle, Fahrenheit, Kelvin, Rankine, Réaumur, Newton and Rømer scales.For more informationread the docs.This package aims to bring the simple and straight to the point,
but precise, Object Oriented experience of working with temperature
scale data types.UsageFirst of all, install the package:pipinstalltotempor, to have an example in poetry environments:poetryaddtotempFor more information, read the docs: [ToTemp Docs]('insert link here')The instances:fromtotempimportCelsius,Fahrenheitif__name__=='__main__':temps:list=[Celsius(12),Celsius(25),Celsius(50)]print(temps[0])# '12 ºC'print(temps)# [Celsius(12), Celsius(25), Celsius(50)]temps=list(map(Celsius.to_fahrenheit,temps))print(temps[0])# '53.6 ºF'print(temps)# [Fahrenheit(53.6), Fahrenheit(77.0), Fahrenheit(122.0)]It's representations and properties:Propertysymbolisread-only.fromtotempimportFahrenheitif__name__=='__main__':temp0=Fahrenheit(53.6)print(temp0.__repr__())# 'Fahrenheit(53.6)'print(temp0.__str__())# '53.6 ºF'print(temp0.symbol)# 'ºF'print(temp0.value)# 53.6Comparision operations ('==', '!=', '>', '>=', '<',...):The comparision/arithmetic implementation attempts to convert the value ofother(if it is a temperature instance) and then evaluate the expression.importtotempastpif__name__=='__main__':temp0,temp1=tp.Celsius(0),tp.Fahrenheit(32)print(f'temp0:{repr(temp0)}')# Celsius(0)print(f'temp1:{repr(temp1.to_celsius())}')# Celsius(0.0)print(temp0!=temp1)# Falseprint(temp0>temp1)# Falseprint(temp0<temp1)# Falseprint(temp0>=temp1)# Trueprint(temp0<=temp1)# Trueprint(temp0==temp1)# TrueArithmetic operations ('+', '-', '*', '**', '/', '//', '%', ...):fromtotempimportNewton,Rankineif__name__=='__main__':temp0=Newton(33)temp1=Rankine(671.67)temp2=temp0+temp1print('temp2:',temp2)# temp2: 65.99999999999999 ºNprint('temp2:',repr(temp2))# temp2: Newton(65.99999999999999)print('temp2:',temp2.value,temp2.symbol)# temp2: 65.99999999999999 ºNprint((temp0+temp1).rounded())# 66 ºNprint(repr((temp0+temp1).rounded()))# Newton(66)print(temp2+12.55)# 78.54999999999998 ºNprint((12+temp2.rounded()))# 78 ºNToTemp classes can work with many built-in Python functions:frommathimportfloor,ceil,truncfromtotempimportReaumurif__name__=='__main__':temp=Reaumur(100.4)float(temp)# 100.4int(temp)# 100round(temp)# Reaumur(100)abs(temp)# Reaumur(100)floor(temp)# Reaumur(100)ceil(temp)# Reaumur(101)trunc(temp)# Reaumur(100)divmod(temp,temp0:=Reaumur(25.1))# (Reaumur(4.0), Reaumur(0.0))Temperature Instance Conversions:importtotempif__name__=='__main__':temp=totemp.Fahrenheit(32)print(temp.to_celsius())# 0.0 ºCprint(temp.to_fahrenheit())# 32 ºFprint(temp.to_delisle())# 150.0 ºDeprint(temp.to_kelvin())# 273.15 Kprint(temp.to_newton())# 0.0 ºNprint(temp.to_rankine())# 491.67 ºRprint(temp.to_reaumur())# 0.0 ºRéprint(temp.to_romer())# 7.5 ºRøChangelog0.1.0:Yanked, not functional;0.2.0:Functional;Can convert Celsius to Delisle, Fahrenheit, Kelvin, Newton, Rankine, Réaumur and Rømer.0.3.0:Changed methods implementations and adds Fahrenheit conversions;<scale_value> parameter is now positional-only;Adds new parameter -> float_ret -> Float Return (True by default, keyword-only);Celsius class methods were updated and enhanced;Can now convert Fahrenheit to Celsius, Delisle, Kelvin, Newton, Rankine, Réaumur and Rømer.0.4.0:There are two new Classes, Kelvin and Delisle, functional and ready-to-use.0.5.1:The implementation has beencompletely refactored:1 -All classes inhehits fromAbstractTemperature(our new abstract  Base Class);2 -All classes now available:Celsius;Fahrenheit;Delisle;Kelvin;(*New)Newton;(*New)Rankine;(*New)Réaumur;(*New)Rømer.3 -New features:The majority of Python's built-in functions works with the instances;More pythonic properties and methods implementations;Arithmetic operations;Comparision operations;convert_to()method;4 -Removals:precise()method;float_ret()param;differentiating int/float;5 -Known problemns:pow()doesn't work as intended;LicenseFor more information, check LICENSE file.