You can use safe_dump instead of dump. Just keep in mind that it won’t be able to represent arbitrary Python objects then. Also, when you load the YAML, you will get a str object instead of unicode.
You can use safe_dump instead of dump. Just keep in mind that it won’t be able to represent arbitrary Python objects then. Also, when you load the YAML, you will get a str object instead of unicode.