Re:Lowbar – The simplest no-nonsense loading bar for Python
by wildmanx on Friday August 05, 2022 @04:59AM
(#32353485)
> since 7 doesn't increase cleanly, I probably have to custom-code the final update to 100 manually,
What do you mean with "not cleanly"?
bar.update_smooth(i * 100 / 7)
Once i is 7, this will be equal to 100. No matter your rounding mode. You don't need a CS degree for that formula.
Re:Lowbar – The simplest no-nonsense loading bar for Python
by HelloNurse on Friday August 05, 2022 @09:51AM
(#32356106)
Percentage calculations require multiplying or dividing by 100 in the right places, complicating both the progress bar itself and client code.
In typical usage it would be more elegant and more general to have a fraction, x things done out of a total of y, with both x and y updateable.
For example, recursively enumerating the contents a file system interleaves increasing y (when subfolders are visited and unprocessed files and unvisited subfolders are found) with increasing x (when files and folders are processed/visited). At the end x catches up with y.
Lowbar could be easily adapted to a percentage-free style without backwards incompatibilities: the constructor could have a parameter, range with default 100, and new methods update_range() and update_range_smooth() could update y similarly to how update() and update_smooth() update x.
Re:Lowbar – The simplest no-nonsense loading bar for Python
by carrotmoncher on Friday August 05, 2022 @06:02AM
(#32353924)
The simplicity of this project isn't really in the usage, but the code base. I guess my main goal was to make a bar that was different from already available loading bars, and give as much control to the user as possible, while keeping the amount of code minimal. Thanks for the feedback though :D
I know every feature added to something simple adds unforeseen levels of complexity, but this choice doesn't eliminate complexity, it just moves the complexity to calling code, and for nearly every use case.