This is not specific to tqdm but a generic question about passing parameters to a function in Python. I want to achieve the following functionality without having to make copies of the entire-block under tqdm. Any help will be greatly appreciated.
if flag == True:
with tqdm(dataloader, total=args.num_train_batches) as pbar:
else:
with tqdm(dataloader) as pbar:
More specifically, can I pass parameters in a way like this?
if flag == True:
tqdm_args = dataloader, total=args.num_train_batches
else:
tqdm_args = dataloader
with tqdm(tqdm_args) as pbar: