serhii.net

In the middle of the desert you can say anything you want

28 Jun 2021

Day 909

Python formatted strings for fun and profit

cocoapi/pycocoDemo.ipynb at master · cocodataset/cocoapi has a nice example of a use case that’s not printlns:

dataDir='..'
dataType='val2017'
annFile='{}/annotations/instances_{}.json'.format(dataDir,dataType)

Nested tqdm loops and pycharm

Nothing was working, neither tqdm nor atpbar, till I used “emulate terminal” in the running config. As soon as I did all bars started working!

Nested loops - for tqdm, nothing needed except just calling it twice. The inner loop, tqdm(iterator, leave=False) removes the 100% completed inner bar and restarts from 0, so only two bars are seen at the same time.

atpbar (alphatwirl/atpbar: Progress bars for threading and multiprocessing tasks on terminal and Jupyter Notebook) is basically like tqdm. Can’t find an option similar to leave=True (though didn’t look), and output looks juuust a bit nicer than vanilla tqdm.

Nel mezzo del deserto posso dire tutto quello che voglio.