Last active
December 25, 2015 10:19
-
-
Save Sanqui/6960326 to your computer and use it in GitHub Desktop.
yaml references example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| types: | |
| - type: &grass | |
| name: "Grass" | |
| advantages: [] | |
| moves: | |
| - move: &vinewhip | |
| power: 40 | |
| type: *grass | |
| pokemon: | |
| - pokemon: &bulbasaur | |
| type1: *grass | |
| moveset: | |
| - move: {level: 5, move: *vinewhip} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> import yaml | |
| >>> import pprint | |
| >>> x = yaml.load(open('test.yaml')) | |
| >>> print x | |
| {'moves': [{'move': {'type': {'advantages': [], 'name': 'Grass'}, 'power': 40}}], 'pokemon': [{'pokemon': {'type1': {'advantages': [], 'name': 'Grass'}, 'moveset': [{'move': {'move': {'type': {'advantages': [], 'name': 'Grass'}, 'power': 40}, 'level': 5}}]}}], 'types': [{'type': {'advantages': [], 'name': 'Grass'}}]} | |
| >>> pprint.pprint(x) | |
| {'moves': [{'move': {'power': 40, | |
| 'type': {'advantages': [], 'name': 'Grass'}}}], | |
| 'pokemon': [{'pokemon': {'moveset': [{'move': {'level': 5, | |
| 'move': {'power': 40, | |
| 'type': {'advantages': [], | |
| 'name': 'Grass'}}}}], | |
| 'type1': {'advantages': [], 'name': 'Grass'}}}], | |
| 'types': [{'type': {'advantages': [], 'name': 'Grass'}}]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment