pint.utils.open_or_use

pint.utils.open_or_use(f: str | Path | IO, mode: Literal['r', 'rb', 'w', 'wb'] = 'r') Iterator[source]

Open a filename or use an open file.

Specifically, if f is a string, try to use it as an argument to open. Otherwise just yield it. In particular anything that is not a subclass of str will be passed through untouched.