class_docstr: Base class for Jupyter applications
docstr: Write our default config to a .py config file
docstr_tok: ["Write","our","default","config","to","a",".py","config","file"]
code: def write_default_config(self):
      """Write our default config to a .py config file"""
      if self.config_file:
          config_file = self.config_file
      else:
          config_file = os.path.join(
              self.config_dir, self.config_file_name + ".py"
          )
  
      if os.path.exists(config_file) and not self.answer_yes:
          answer = ""
  
          def ask():
              prompt = (
                  "Overwrite %s with default config? [y/N]"
                  % config_file
              )
              try:
                  return raw_input(prompt).lower() or "n"
              except KeyboardInterrupt:
                  print("")  # empty line
                  return "n"
  
          answer = ask()
          while not answer.startswith(("y", "n")):
              print("Please answer 'yes' or 'no'")
              answer = ask()
          if answer.startswith("n"):
              return
  
      config_text = self.generate_config_file()
      if isinstance(config_text, bytes):
          config_text = config_text.decode("utf8")
      print("Writing default config to: %s" % config_file)
      ensure_dir_exists(
          os.path.abspath(os.path.dirname(config_file)), 0o700
      )
      with open(config_file, mode="w") as f:
          f.write(config_text)
  
imports: from __future__ import print_function
  from copy import deepcopy
  import logging
  import os
  import sys
  from traitlets.config.application import Application, catch_config_error
  from traitlets.config.loader import ConfigFileNotFound
  from traitlets import Unicode, Bool, List, observe
  from .utils import ensure_dir_exists
  from ipython_genutils import py3compat
  from .paths import jupyter_config_dir, jupyter_data_dir, jupyter_runtime_dir, jupyter_path, jupyter_config_path, allow_insecure_writes, issue_insecure_write_warning
label_desc: Use image node_id 9 for calling the JupyterApp obj's underlying member method code with example usage: obj.write_default_config() and returns: unknown, str