Performing arithmetic operation in YAML?
This can be accomplished by using the Python-specific tags offered by PyYAML, i.e.:
!!python/object/apply:eval [ 1 * 24 * 60 * 60 ]
As demonstrated in the below:
In [1]: import yaml
In [2]: yaml.load("!!python/object/apply:eval [ 1 * 24 * 60 * 60 ]")
Out[2]: 86400
This is, naturally, the same as performing eval(config['some_time'])
, but saves you from having to handle it explicitly in your program.
I don't think there is. At least not on spec (http://yaml.org/spec/1.2/spec.html). People add non-official tags to yaml (and wikipedia seems to say there's proposal for a yield tag, though they don't say who proposed or where: http://en.wikipedia.org/wiki/YAML#cite_note-16), but nothing like you need seems to be available in pyyaml.
Looking at pyyaml specific tags there doesn't seem to be anything of interest. Though !!timestamp '2014-08-26'
may be handy in some of your scenarios (http://pyyaml.org/wiki/PythonTagScheme).