#๐ class atrabute cant be set
26 messages ยท Page 1 of 1 (latest)
@opal quest
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
class atrabute
Is it a class attribute or instance attribute? If you have a class attribute and try to assign it onself, the debugger might be getting confused.
What's the whole class definition? @opal quest
So that's not the case.
self.wtf = 1 will definitely assign the value 1 to self.wtf, so I'd double check that the value isn't be reassigned elsewhere.
Ya, like there: self.wtf = int(self.get_size_bytes() / self._type_size)
that should never get called tho. welp ill investigate some more
Well, there's two other places self.wtf is assigned. I'd put prints at each place.
Also, I don't see where it would happen here, but note that __len__ is called if you don't define __bool__ and you try to treat the object as a boolean value.
I'm not sure why it would do that. It shouldn't need to query the length, unless it does that to show a length in the watch panel or something.
Out of curiosity, if you define __bool__ on the class, does it stop calling __len__?
Wait, now I'm confused:
still calls it
Wait, ya, I was right, it's for the watch panel:
It tries to see if the class defines a length so it can show it
T: 5, where 5 is the length

I got bit by a similar bug where I had a custom list class that defined a __str__ method. I created a massive instance of the list, then the debugger insisted on calling str on it constantly and bogged down the debugging.
debuger becomes a rebugger
THe circle of life
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.