jpayne@68: """ jpayne@68: Automatically choose between `tqdm.notebook` and `tqdm.std`. jpayne@68: jpayne@68: Usage: jpayne@68: >>> from tqdm.autonotebook import trange, tqdm jpayne@68: >>> for i in trange(10): jpayne@68: ... ... jpayne@68: """ jpayne@68: import sys jpayne@68: from warnings import warn jpayne@68: jpayne@68: try: jpayne@68: get_ipython = sys.modules['IPython'].get_ipython jpayne@68: if 'IPKernelApp' not in get_ipython().config: # pragma: no cover jpayne@68: raise ImportError("console") jpayne@68: from .notebook import WARN_NOIPYW, IProgress jpayne@68: if IProgress is None: jpayne@68: from .std import TqdmWarning jpayne@68: warn(WARN_NOIPYW, TqdmWarning, stacklevel=2) jpayne@68: raise ImportError('ipywidgets') jpayne@68: except Exception: jpayne@68: from .std import tqdm, trange jpayne@68: else: # pragma: no cover jpayne@68: from .notebook import tqdm, trange jpayne@68: from .std import TqdmExperimentalWarning jpayne@68: warn("Using `tqdm.autonotebook.tqdm` in notebook mode." jpayne@68: " Use `tqdm.tqdm` instead to force console mode" jpayne@68: " (e.g. in jupyter console)", TqdmExperimentalWarning, stacklevel=2) jpayne@68: __all__ = ["tqdm", "trange"]