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

Reassign the value of an outline table, the table becomes messy. #29

Closed
frostming opened this issue Nov 9, 2018 · 1 comment
Closed

Comments

@frostming
Copy link
Contributor

frostming commented Nov 9, 2018

Issue

Given this file:

[site.user]
name = "John"

Then re-assign the table to be a string:

parsed = tomlkit.parse(open("my.toml").read())
parsed['site']['user']="Tom"
print(parsed.as_string())

gives:

user = "Tom"

The table header is missing!
tomlkit version: v0.5.1

Workaround

One needs to reassign the parent:

v = parsed['site']
parsed['site'] = v.copy()
parsed['site']['user']="Tom"
print(parsed.as_string())
[site]
user = "Tom"
@sdispater
Copy link
Member

This is fixed in the latest 0.5.2 release.

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

2 participants