tqdm.autonotebook

- adds documentation and `pandas()` example (#474)
- closes #443
This commit is contained in:
Casper da Costa-Luis 2018-05-31 17:08:29 +01:00
parent 0307fd18eb
commit 97a9393274
No known key found for this signature in database
GPG Key ID: 986B408043AE090D
2 changed files with 27 additions and 0 deletions

View File

@ -665,6 +665,18 @@ light blue: no ETA); as demonstrated below.
|Screenshot-Jupyter2|
|Screenshot-Jupyter3|
It is also possible to let ``tqdm`` automatically choose between
console or notebook versions by using the ``autonotebook`` submodule:
.. code:: python
from tqdm.autonotebook import tqdm
tqdm.pandas()
Note that this will issue a ``TqdmExperimentalWarning`` if run in a notebook
since it is not meant to be possible to distinguish between ``jupyter notebook``
and ``jupyter console``.
Writing messages
~~~~~~~~~~~~~~~~

View File

@ -0,0 +1,15 @@
try:
from IPython import get_ipython
if 'IPKernelApp' not in get_ipython().config:
raise ImportError("console")
except:
from .._tqdm import tqdm, trange
else:
from .._tqdm_notebook import tqdm_notebook as tqdm
from .._tqdm_notebook import tnrange as trange
from .._tqdm import TqdmExperimentalWarning
from warnings import warn
warn("Using `tqdm.autonotebook.tqdm` in notebook mode."
" Use `tqdm.tqdm` instead to force console mode"
" (e.g. in jupyter console)", TqdmExperimentalWarning)
__all__ = ["tqdm", "trange"]