-
-
Notifications
You must be signed in to change notification settings - Fork 411
Open
Labels
Description
Resolving #165 allowed setting the default for an attribute based on other attributes using a decorator like this:
@attrs(frozen=True, slots=True)
class Foo:
bar = attr.ib()
moo = attr.ib()
@moo.default
def _init_moo(self):
return self.bar + 2
Many times in frozen classes we want to derive one attribute from another without giving the user the opportunity to override it. The Immutables library for Java provides for this via Value.Derived: http://immutables.github.io/immutable.html#derived-attributes . Perhaps attrs could have a @field.derived decorator which does the same thing?