With the tqdm package, according to https://github.com/tqdm/tqdm/issues/375, a different thing needs to be imported based on whether a progress bar is required on a jupyter notebook [from tqdm import tqdm_notebook as tqdm
] or in the terminal [from tqdm import tqdm
].
I'm writing a script which makes used of tqdm to display a progress bar, but I don't know whether the user is going to use the script in a Jupyter notebook or a terminal. How can I give it some context awareness so that if the user is calling the script from a jupyter notebook, then it uses tqdm_notebook, and otherwise it uses tqdm.
So, the question is: how can I detect if the environment the script is being called in is a Jupyter notebook.