Skip to content

Instantly share code, notes, and snippets.

@emolch
Created July 10, 2017 09:37
Show Gist options
  • Save emolch/a0f54f8e47fc16ee9e7b892b8dc2014e to your computer and use it in GitHub Desktop.
Save emolch/a0f54f8e47fc16ee9e7b892b8dc2014e to your computer and use it in GitHub Desktop.
How to create child objects with defaults with guts
from pyrocko.guts import Object, Float
class Location(Object):
lat = Float.T()
lon = Float.T()
class Setup(Object):
location = Location.T(default=Location.D(lat=10., lon=20.))
setup1 = Setup()
setup2 = Setup()
setup1.location.lat = 33.
setup1.location.lon = 44.
print setup2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment