Skip to content
Advertisement

Adding dynamic attribute to python class fails

I’m trying to dynamically add an attribute to some class from javalang:

JavaScript

But when I try to simply assign a new attribute (qualifier_type)

JavaScript

Nothing happens:

JavaScript

Advertisement

Answer

Apparently, my attribute was there all the time, it just wasn’t printed, since the __repr__ implementation iterated over self.attrs.

JavaScript

Explicitly adding my attribute, I can now print my class (scroll to the right to see it)

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement