Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dict update/copying is not correctly observed #496

Closed
DGothrek opened this issue Jul 23, 2018 · 2 comments
Closed

Dict update/copying is not correctly observed #496

DGothrek opened this issue Jul 23, 2018 · 2 comments

Comments

@DGothrek
Copy link

The behavior of the copy function is not the ideal one (already reported), but copying it by hand doesn't work either.

class Foo(HasTraits):
    bar = Dict()

    @observe('bar')
    def _observe_bar(self, change):
        print(change['new'])

foo = Foo()

foo.bar = {}  # prints {}
foo.bar['foo'] = 'foo'  # does not observe that change
foo.bar = copy(foo.bar) # both changes are not observed either.
foo.bar = deepcopy(foo.bar)
foo.bar = {'foo': 'foo'} # not observed !
foo.bar = {'foo':'bar'} # observed
foo.bar = {'bar':'bar'} # observed

outputs :

{}
{'foo': 'bar'}
{'bar': 'bar'}

Is it a normal behavior ?

@rmorshea
Copy link
Contributor

rmorshea commented Aug 6, 2018

@DGothrek

See this issue:

#495

This comment:

#495 (comment)

And this PR:

#466

@DGothrek
Copy link
Author

DGothrek commented Aug 7, 2018

I had seen the issue, but not the PR ! Thanks a lot, that's impressive :-D

@DGothrek DGothrek closed this as completed Aug 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants