rsalmei / alive-progress

A new kind of Progress Bar, with real-time throughput, ETA, and very cool animations!
MIT License
5.53k stars 206 forks source link

Doc and option to get a bar without with keyword #219

Closed latot closed 1 year ago

latot commented 1 year ago

Hi!, I think would be great have a little of doc of how to use the alive bar without with keyword.

But Why?, in other language there should be no problem, but in python there is tab rule... so, every time we want a bar we need to tab blocks and blocks, if we want to remove it, untab again D:

In the dev process this is far from easy to use. And too much tabs causes to be hard to read the code, we are already forced to use tabs for a lot of things, has the option to avoid it, can helps readability too.

Maybe a direct use of __enter__ and __exit__ is not the best for this case.

Thx!

rsalmei commented 1 year ago

Hi! You can find some examples of that kind of use here in other issues, I can quickly find #44 and #200, but there should be more. You could also use the auto-iterating version alive_it, it is a great way to not use any context manager.

Regarding docs about it, I don't want to actually include any because this is not recommended. I chose to make this progress bar using context managers because it makes it much easier for the user. I needed to guarantee certain functions ran when entering and exiting the bar so that the screen wouldn't ever get in a weird state, as well as the logging system, the printing system, and the threading system... But using without them you risk calling things wrong and messing with all of them. It's too much of a risk. Thanks.