'Parse and execute single line of a readline init file.'

def parse_and_bind(self, string):

    try:
        log(('parse_and_bind("%s")' % string))
        if string.startswith('#'):
            return
        if string.startswith('set'):
            m = re.compile('set\\s+([-a-zA-Z0-9]+)\\s+(.+)\\s*$').match(string)
            if m:
                var_name = m.group(1)
                val = m.group(2)
                try:
                    setattr(self, var_name.replace('-', '_'), val)
                except AttributeError:
                    log(('unknown    var="%s"    val="%s"' % (var_name, val)))
            else:
                log(('bad    set    "%s"' % string))
            return
        m = re.compile('\\s*(.+)\\s*:\\s*([-a-zA-Z]+)\\s*$').match(string)
        if m:
            key = m.group(1)
            func_name = m.group(2)
            py_name = func_name.replace('-', '_')
            try:
                func = getattr(self.mode, py_name)
            except AttributeError:
                log(('unknown    func    key="%s"    func="%s"' % (key, func_name)))
                print ('unknown    function    to    bind:    "%s"' % func_name)
            self.mode._bind_key(key, func)
    except:
        log('error')
        raise
