enthought / enthought/traits

strange `post_init` behavior with `on_trait_change`

Open
#275 3 comments 0 reactions 0 assignees View on GitHub
priority: low topic: traits listener rework type: bug
Dominant language
Python
Stars
462
Forks
90
PR merge metrics
No merged PRs in 30d

Description

```
from traits.api import HasStrictTraits, Event, on_trait_change, List, Instance
class Baby(HasStrictTraits):
cry = Event

class Mom(HasStrictTraits):
babies = List(Baby)
@on_trait_change('babies:cry', post_init=True)
def respond(self):
print 'calm down!'

babies = [Baby() for i in xrange(3)]
mom = Mom(babies=babies)
mom.babies[0].cry = True
```

the `Mom` object doesn't respond to `cry` with `post_init=True`, but works when `post_init=False`. This shouldn't affect the `on_trait_change` call.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.