Skip to content

Instantly share code, notes, and snippets.

@claudep
Created January 8, 2013 09:04
Show Gist options
  • Save claudep/4482355 to your computer and use it in GitHub Desktop.
Save claudep/4482355 to your computer and use it in GitHub Desktop.
import datetime
import yaml
class Obj1(object):
def __init__(self, dt):
self.dt = dt
dt = datetime.datetime(2011, 9, 1, 13, 20, 30, 405060)
o1 = Obj1(dt)
yaml.dump(o1)
> "!!python/object:__main__.Obj1 {dt: !!timestamp '2011-09-01 13:20:30.405060'}\n"
yaml.dump(o1, Dumper=yaml.CDumper)
> "!!python/object:__main__.Obj1 {dt: ! '2011-09-01 13:20:30.405060'}\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment