Skip to content

How to set an Module attribute after constructing it? #1220

Answered by marcvanzee
marcvanzee asked this question in Q&A
Discussion options

You must be logged in to vote

You can use object.__setattr__:

object.__setattr__(decoder_head, 'decode_embedded_targets', mock.Mock(side_effect=decoder_head.decode_embedded_targets)

Replies: 1 comment

Comment options

marcvanzee
Apr 8, 2021
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by marcvanzee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant