def register_option(key, defval, doc='<STR_LIT>', validator=None, cb=None):
import tokenize<EOL>import keyword<EOL>key = key.lower()<EOL>if key in _registered_options:<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise OptionError(msg.format(key=key))<EOL><DEDENT>if key in _reserved_keys:<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise OptionError(msg.format(key=key))<EOL><DEDENT>if validator:<EOL><INDENT>validator(defval)<EOL><DEDENT>path = key.split('<STR_LIT:.>')<EOL>for k in path:<EOL><INDENT>if not bool(re.match('<STR_LIT>' + tokenize.Name + '<STR_LIT:$>', k)):<EOL><INDENT>raise ValueError("<STR_LIT>".format(k=k))<EOL><DEDENT>if keyword.iskeyword(k):<EOL><INDENT>raise ValueError("<STR_LIT>".format(k=k))<EOL><DEDENT><DEDENT>cursor = _global_config<EOL>msg = "<STR_LIT>"<EOL>for i, p in enumerate(path[:-<NUM_LIT:1>]):<EOL><INDENT>if not isinstance(cursor, dict):<EOL><INDENT>raise OptionError(msg.format(option='<STR_LIT:.>'.join(path[:i])))<EOL><DEDENT>if p not in cursor:<EOL><INDENT>cursor[p] = {}<EOL><DEDENT>cursor = cursor[p]<EOL><DEDENT>if not isinstance(cursor, dict):<EOL><INDENT>raise OptionError(msg.format(option='<STR_LIT:.>'.join(path[:-<NUM_LIT:1>])))<EOL><DEDENT>cursor[path[-<NUM_LIT:1>]] = defval  <EOL>_registered_options[key] = RegisteredOption(key=key, defval=defval,<EOL>doc=doc, validator=validator,<EOL>cb=cb)<EOL>
Register an option in the package-wide pandas config object

    Parameters
    ----------
    key       - a fully-qualified key, e.g. "x.y.option - z".
    defval    - the default value of the option
    doc       - a string description of the option
    validator - a function of a single argument, should raise `ValueError` if
                called with a value which is not a legal value for the option.
    cb        - a function of a single argument "key", which is called
                immediately after an option value is set/reset. key is
                the full name of the option.

    Returns
    -------
    Nothing.

    Raises
    ------
    ValueError if `validator` is specified and `defval` is not a valid value.