Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments in multiline array #340

Open
andreasdoll opened this issue Apr 19, 2024 · 0 comments
Open

Comments in multiline array #340

andreasdoll opened this issue Apr 19, 2024 · 0 comments

Comments

@andreasdoll
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant