On 23/03/22 7:00 am, Avi Gross wrote:
But are there costs or even errors if you approach an inner part of an object directly? Can there be dunder methods not invoked that would be from the standard approach? What kind of inadvertent errors can creep in?
The attribute could be a property that returns different objects at different times depending on some condition. In that case you will need to think about whether you want the current value of the attribute, or the value it had when you looked it up before. Concerning dunder methods, there are a bunch of them involved in looking up an attribute of an object. Theoretically it's possible for these to have side effects and for bad things to happen if you skip them. But that would be very unusual and surprising, and we generally assume such things don't happen. -- Greg -- https://mail.python.org/mailman/listinfo/python-list