Closed scifinder closed 4 months ago
By default, the top-level data structure is required to be a dictionary. If you want to allow lists or strings instead, use the top
argument to nt.load()
:
$ cat list.nt
- a
- b
$ python
Python 3.10.0 (default, Oct 20 2021, 17:23:57) [Clang 12.0.1 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nestedtext as nt
>>> nt.load('list.nt', top='list')
['a', 'b']
That said, the error message should be much clearer about this, and the documentation example should probably mention this issue as well.
Thank you for the clarification!
I read about the top
parameter in the documentation, but did not focus on it. Indeed, everything is working now.
Thank you for the wonderful format! The representation of all parameters in the form of text, without casting to other types, is exactly what I was looking for to describe the samples of my mineralogical collection! =)
The representation of all parameters in the form of text, without casting to other types, is exactly what I was looking for
Us too, glad you like the format!
Hello! I get a
NestedTextError
exception when I try to parse an example from the documentation starting with a dash:My code:
I have found out experimentally that this error appears whenever the dash is the first character in the document. Even such a document causes this error:
But this one parses without errors:
It looks like a bug.