ipython / ipython/traitlets

execution order of trait observers

Aperta
#874 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
653
Fork
217
Merge medio
2g 21h
PR unite (30g)
2

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.