def to_hdf(path_or_buf, key, value, mode=None, complevel=None, complib=None,<EOL>append=None, **kwargs):
if append:<EOL><INDENT>f = lambda store: store.append(key, value, **kwargs)<EOL><DEDENT>else:<EOL><INDENT>f = lambda store: store.put(key, value, **kwargs)<EOL><DEDENT>path_or_buf = _stringify_path(path_or_buf)<EOL>if isinstance(path_or_buf, str):<EOL><INDENT>with HDFStore(path_or_buf, mode=mode, complevel=complevel,<EOL>complib=complib) as store:<EOL><INDENT>f(store)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>f(path_or_buf)<EOL><DEDENT>
store this object, close it if we opened it