Hey there!
I finally made first release of **blusutils Python library**! No word yet on when the first big release will be, but I'm working on it.
Features of this release:
Switch/Case for Python older 3.10 and with any comparison modes:
py
from blusutils.syntax_constructions import switch
with switch(input('How are you?')) as case:
if case('good'):
...
elif case('bad'):
...
else: default
...
Download time calculation:
py
import blusutils
from blusutils.other import Metrics as metr
print(blusutils.other.calculate_downloading_time(10, 100, [metr.Megabytes, metr.Kilobytes]))
output: 0, 1, 42, 102 (0 hours, 1 minute, 42 seconds, 102 seconds in total to download 10 megabytes with speed 100 kilobytes)
Safeand anywhere raising of exceptions:
py
import blusutils
def ternary(inp: int):
return inp if isinstance(inp, int) else blusutils.other.anywhere_raise(TypeError('inp is not an integer'))
this simular to:
if not isinstance(inp, int):
raise TypeError('inp is not an integer')
return inp
def safe_error():
print(1+1)
blusutils.other.safe_raise(ValueError('Safe'))
def test():
print('Look here!')
safe_error() this will only print exception, but don't stop code
print('still working? okay...')
ternary('Not an integer!') exception
...and any more!