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

Doesn't Work At All For Lists / Arrays? #197

Open
JimLynchCodes opened this issue Apr 29, 2023 · 4 comments
Open

Doesn't Work At All For Lists / Arrays? #197

JimLynchCodes opened this issue Apr 29, 2023 · 4 comments

Comments

@JimLynchCodes
Copy link

JimLynchCodes commented Apr 29, 2023

yaml code:

name: "something"
posessions:
  - bar
  - Towel
  - Foo

python code:

from strictyaml import load, Map, Str, Int, Seq, YAMLError

with open("my-data.yaml", "r") as stream:
    try:
        data = load(stream)
        print(data)
    except YAMLError as error:
        print(error)

Executing this code incorrectly prints an error about the colon:

  File "data.yaml", line 2
    posessions:
                      ^
SyntaxError: invalid syntax
@crdoconnor
Copy link
Owner

You are trying to run the YAML file with the python interpreter, not the python code.

@JimLynchCodes
Copy link
Author

JimLynchCodes commented Apr 30, 2023

Can you add code examples to the README please?

I don't hardly ever use python other than in google colab 😅

@JimLynchCodes
Copy link
Author

@crdoconnor what is the python code way to do this?

@crdoconnor
Copy link
Owner

If that file is called "mycode.py" you run "python mycode.py".

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