'Create instance, set defaults and do argument processing.'

def __init__(self, stdin=None, stdout=None, stderr=None, encoding='utf8', args=None, db=None):

    super(Shell, self).__init__()
    self.exceptions = False
    self.history_file = '~/.sqlite_history'
    self._db = None
    self.dbfilename = None
    if db:
        self.db = (db, db.filename)
    else:
        self.db = (None, None)
    self.prompt = 'sqlite>    '
    self.moreprompt = '                ..>    '
    self.separator = '|'
    self.bail = False
    self.echo = False
    self.timer = False
    self.header = False
    self.nullvalue = ''
    self.output = self.output_list
    self._output_table = self._fmt_sql_identifier('table')
    self.widths = []
    self.truncate = True
    self._output_stack = []
    self.set_encoding(encoding)
    if (stdin is None):
        stdin = sys.stdin
    if (stdout is None):
        stdout = sys.stdout
    if (stderr is None):
        stderr = sys.stderr
    self.stdin = stdin
    self.stdout = stdout
    self._original_stdout = stdout
    self.stderr = stderr
    self.interactive = None
    self.command_colour()
    self._using_readline = False
    self._input_stack = []
    self.input_line_number = 0
    self.push_input()
    self.push_output()
    self._input_descriptions = []
    if args:
        try:
            self.process_args(args)
        except:
            if len(self._input_descriptions):
                self._input_descriptions.append('Processing    command    line    arguments')
            self.handle_exception()
            raise
    if (self.interactive is None):
        self.interactive = (getattr(self.stdin, 'isatty', False) and self.stdin.isatty() and getattr(self.stdout, 'isatty', False) and self.stdout.isatty())
