question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Get value of key of type Enum as string?

See original GitHub issue

Getting the value of a key of type Enum as string feels not intuitive for me. Am I doing it correctly?

from strictyaml import Map, Enum, load, YAML

yaml_snippet = """
a: A
"""
schema = Map({"a": Enum(["A", "B", "C"])})
parsed = load(yaml_snippet, schema)
# parsed is YAML(OrderedDict([('a', YAML(A))]))
# parsed['a'].value is YAML(A)
# parsed['a'].value.value is 'A'
# parsed['a'].data.data is 'A'

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
fkromercommented, Nov 5, 2018

Thx a lot. It’s working just fine now!

1reaction
crdoconnorcommented, Nov 5, 2018

Ok fixed in 0.15.3, released just a second ago.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get names of enum entries? - typescript - Stack Overflow
In JS enum is an object of [value]: name so you can get all values like that Object.keys(enum) , all names Object.values(enum) and...
Read more >
Typescript enum get key by value, value by key, use as object ...
Explains how to get value by key, get key by value, and use an enum as an object key. Some functions don't behave...
Read more >
TypeScript Enums—Look up the name (key) of a string-based ...
We can look up an enums member name (key) given its number (value) like this: Enums support accessing data in both directions from...
Read more >
Top 8 functions you'll ever need to work with Enums in ...
1. Check if a key is property of enum · 2. Check if enum has a given value · 3. Transform enum to...
Read more >
Getting enum keys in TypeScript - Crojach Software
While working on a task, my colleague stumbled upon a quirky problem. He tried to fetch all keys out of an enum but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found