Created
July 2, 2015 06:44
-
-
Save jaidevd/b4c4cfb35b8762aeb8ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from traits.api import HasTraits, Property, Dict, cached_property, Any, Str, Int | |
class MyTraits(HasTraits): | |
a = Any | |
b = Property(Dict(key_trait=Str, value_trait=Int), depends_on=['a']) | |
@cached_property | |
def _get_b(self): | |
return {'a': self.a} | |
if __name__ == '__main__': | |
mt = MyTraits(a='hello') | |
print mt.b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Only trait setters are validated, getters are not: