Custom Query (121 matches)
Results (85 - 87 of 121)
| Ticket | Resolution | Summary | Owner | Reporter |
|---|---|---|---|---|
| #167 | worksforme | Please help saving dict to yaml | xi | anonymous |
| Description |
Hi, is there any way of saving dict to a file in yaml format? I'm using:
----------------------------------------
#!/usr/bin/python
import yaml
y = """
root:
- subject1:
desc: msg1
- subject2:
desc: msg2
"""
settings=yaml.load(y)
settings['root'][0]['subject1']['desc'] = "new msg"
print settings
f = open("temp", "w")
f.write(str(settings))
----------------------------------------
but failing miserably, contents of the temp file:
{'root': [{'subject1': {'desc': 'new msg'}}, {'subject2': {'desc': 'msg2'}}]}
expected result:
root:
- subject1:
desc: new msg
- subject2:
desc: msg2
Is there anything like yaml.save? Any help greatly appreciated!
Regards,
Tomas
|
|||
| #41 | fixed | Patch: Use types module instead of hand crafted entities and type(). | xi | v.haisman@… |
| Description |
Hi, I have a patch that makes PyYAML use types module instead of hand crafted entities and type(). The motivation is that it silences some PyDev? error complains, like methods not having self parameter and such. |
|||
| #5 | fixed | PYYAML3000 does not load recursive structures. | xi | pkmurphy@… |
| Description |
PYYAML does not load any structure with an anchor that contains its own alias. For example: ourconst2 = "---\n!!seq &base [ *base ] \n...\n"; print ourconst2; for event in yaml.parse(ourconst2): print event ourload = yaml.safe_load(ourconst2) print ourload; |
|||
Note: See TracQuery
for help on using queries.
