ipython / ipython/traitlets

execution order of trait observers

Open
#874 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
653
Forks
217
Avg merge
2d 21h
Merged PRs (30d)
2

Description

its not clear to me in what order the trait observers get executed and why?
can anyone shed light on this?

```py
class Test(tr.HasTraits):
a = tr.Bool(default_value=True)
b = tr.Bool(default_value=True)
c = tr.Bool(default_value=True)

@tr.observe("a")
def _a(self, on_change):
print(f"a = {self.a}")

@tr.observe("b")
def _b(self, on_change):
print(f"b = {self.b}")

@tr.observe("c")
def _c(self, on_change):
print(f"c = {self.c}")

def __init__(self, **kwargs):
super().__init__(**kwargs)

t1 = Test(a=False, b=False, c=False)
print("---")
t2 = Test(c=False, b=False, a=False)

# b = False
# c = False
# a = False
# ---
# b = False
# c = False
# a = False
```

many thanks

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.