Skip to content

Commit 26e5e30

Browse files
author
y-p
committed
ENH/CLN: add helpers for ipnb detection
1 parent 9209345 commit 26e5e30

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

pandas/core/common.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -1904,8 +1904,23 @@ def in_qtconsole():
19041904
return True
19051905
except:
19061906
return False
1907+
return False
1908+
1909+
def in_ipnb():
1910+
"""
1911+
check if we're inside an IPython Notebook
1912+
"""
1913+
try:
1914+
ip = get_ipython()
1915+
front_end = (ip.config.get('KernelApp',{}).get('parent_appname',"") or
1916+
ip.config.get('IPKernelApp',{}).get('parent_appname',""))
1917+
if 'notebook' in front_end.lower():
1918+
return True
1919+
except:
1920+
return False
1921+
return False
19071922

1908-
def in_ipnb_frontend():
1923+
def in_ipython_frontend():
19091924
"""
19101925
check if we're inside an an IPython zmq frontend
19111926
"""

pandas/core/format.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,7 @@ def get_console_size():
17181718
# Simple. yeah.
17191719

17201720
if com.in_interactive_session():
1721-
if com.in_ipnb_frontend():
1721+
if com.in_ipython_frontend():
17221722
# sane defaults for interactive non-shell terminal
17231723
# match default for width,height in config_init
17241724
from pandas.core.config import get_default_val

0 commit comments

Comments
 (0)