News for hackers. Stuff that matters.
Re:Lowbar – The simplest no-nonsense loading bar for Python by ottoflux on Friday August 05, 2022 @10:36AM (#32356691)
I love this. One tiny thought - perhaps use a conditional when setting the string percentage/completion value to prepend a 0 of it's < 10?

like: completion_string: str = '0' + str(self.completion) if self.completion < 10 else str(self.completion)

basically it would keep your bar from shifting when percentage goes from single digit to double digit.

Re:Lowbar – The simplest no-nonsense loading bar for Python by carrotmoncher on Friday August 05, 2022 @11:02AM (#32357128)
This is a pretty good idea, thank you! I will implement this, but instead of a zero ill use a whitespace
Re:Lowbar – The simplest no-nonsense loading bar for Python by dangrie158 on Friday August 05, 2022 @02:01PM (#32359628)
You may want to use Format specifiers or fstrings (>py36) for a „more pythonic“ code.

Also why do you annotate every variable, even if the type can be deduced automatically? That’s going to be a real PITA if you want to refactor the code e.g to support floats instead of ints any time in the future (in this case it’s probably just a hypothetical problem)

Re:Lowbar – The simplest no-nonsense loading bar for Python by carrotmoncher on Friday August 05, 2022 @11:52PM (#32364681)
its mostly for myself, i prefer to annotate variables so i can quickly know what type they should be when writing code (especially for bigger projects). I guess since lowbar is small, its pretty pointless, but its just a habit thats been stuck