tomlkit
tomlkit copied to clipboard
Comments in multiline array
Hello
I have two questions regarding comments in multiline arrays (for which I couldn't find documentation).
I'm using tomlkit 0.12.4. Consider the following code:
import tomlkit
content = """[foo]
bar = [
"one", # comment one
"two", # comment two
]
"""
data = tomlkit.loads(content)
- Is there a way to read the comments with respect to the array entries?
I was expecting data["foo"]["bar"][0].trivia
, but this doesn't have information about the comment (neither does data["foo"]["bar"].trivia
).
I know I can do data["foo"]["bar"].as_string()
but there I'd have to parse them myself from the string.
- (How) can I write multiline arrays with comments?
Thanks in advance!