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

Loading to named tuple #52

Closed
worldmind opened this issue Mar 28, 2019 · 2 comments
Closed

Loading to named tuple #52

worldmind opened this issue Mar 28, 2019 · 2 comments

Comments

@worldmind
Copy link

Hi,
Thanks for interesting project - we live in very strange world, where so basic things like human readable file format has no good and popular solution.
StrictYAML looks like good candidate.
I have a small question/feature request - is it possible to load StrictYAML file not to OrderedDict, but to named tuple?
Where is two reasons for this:

  1. It's immutable - for example, it's more safe for global config.
  2. It's more readable: you can write person.name instead person['name']
@crdoconnor
Copy link
Owner

crdoconnor commented Mar 28, 2019

Thanks!

I'm afraid it's not possible to load to named tuple directly. StrictYAML is designed to allow roundtripping, so mutability is built in by default.

That said - it should be relatively straightforward to use something like this to take the output of .data and replace the dicts with named tuples.

If more people request this I might consider putting this function in the library directly, but for now it feels like something that belongs outside of it.

@worldmind
Copy link
Author

Ok, thanks for answer.

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