Now I\'m dumping into a YAML document. It\'s working as it should for the most part. When I try to dump a hexadecimal such as \"0x2A\" it converts to 42. Isn\'t there any wa
This should do it:
>>> import yaml >>> class HexInt(int): pass ... >>> def representer(dumper, data): ... return yaml.ScalarNode('tag:yaml.org,2002:int', hex(data)) ... >>> yaml.add_representer(HexInt, representer) >>> yaml.dump({"n": HexInt(42)}) '{n: 0x2a}\n'