File tree 1 file changed +3
-2
lines changed
src/py-opentimelineio/opentimelineio/core
1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -240,7 +240,7 @@ def wrapped_update(data):
240
240
return decorator_func
241
241
242
242
243
- def serializable_field (name , required_type = None , doc = None ):
243
+ def serializable_field (name , required_type = None , doc = None , default_value = None ):
244
244
"""
245
245
Convenience function for adding attributes to child classes of
246
246
:class:`~SerializableObject` in such a way that they will be serialized/deserialized
@@ -274,13 +274,14 @@ class Foo(SerializableObject):
274
274
:param str name: name of the field to add
275
275
:param type required_type: type required for the field
276
276
:param str doc: field documentation
277
+ :param Any default_value: default value to return if no field value is set yet
277
278
278
279
:return: property object
279
280
:rtype: :py:class:`property`
280
281
"""
281
282
282
283
def getter (self ):
283
- return self ._dynamic_fields [ name ]
284
+ return self ._dynamic_fields . get ( name , default_value )
284
285
285
286
def setter (self , val ):
286
287
# always allow None values regardless of value of required_type
You can’t perform that action at this time.
0 commit comments