fabiocaccamo / python-benedict

:blue_book: dict subclass with keylist/keypath support, built-in I/O operations (base64, csv, html, ini, json, pickle, plist, query-string, toml, xls, xml, yaml), s3 support and many utilities.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for `pathlib.Path`.

svisser opened this issue · comments

This is an issue to explore adding support for Python's pathlib. At the moment the following works:

>>> d = benedict("test.json", format="json")
>>> d
{'test': 123}

but the following raises an error:

>>> import pathlib
>>> d = benedict(pathlib.Path("test.json"), format="json")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  ....
  File ".../lib/python3.11/site-packages/benedict/dicts/parse/parse_dict.py", line 15, in __init__
    super(ParseDict, self).__init__(*args, **kwargs)
  File ".../lib/python3.11/site-packages/benedict/dicts/base/base_dict.py", line 30, in __init__
    super(BaseDict, self).__init__(*args, **kwargs)
TypeError: 'PosixPath' object is not iterable

@svisser fixed in 0.28.1 version.