Skip to content

HDFStore to work with 'with' statements #8791

Closed
@0zeroth

Description

@0zeroth

This should work:

    with pandas.HDFStore('file.h5') as f:
        print(f)

as a more convenient form of

    with contextlib.closing(pandas.HDFStore('file.h5')) as f:
         print(f)

AFAIK this is a easy as adding the following to HDFStore

    def _enter_(self): pass
    def _exit_(self): self.close()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions