def is_notebook():
 try:
  get_ipython()
  return True
 except NameError:
  return False

def is_notebook ( ) : try : get_ipython ( ) return True except NameError : return False
test whether we are inside an ipython notebook .