I once spent a lot of time trying to implement lazy loading by modifying a class __getattribute__ so that it would initialize the instance and then set the instance __getattribute__ to object.__getattribute__ ... Obviously it did not work, as instance.__getattribute__ is never called, I wish I had known the behavior before, it would have prevented me from loosing a lot of time 😄
@@anthonywritescode ah right, it would work without the lambda because exit does take an argument, but what is passed as self would be taken as an exit-code. Thanks!
But wait... That's exactly how I would expect it to work...
YOU KNOW TOO MUCH
I could watch this all day
hah well fortunately the playlist is about ~60 hours of content :)
twitch!
Instead of using a lambda function, you could use (can't render correctly on a youtube comment):
"type(exit).__repr__ = type(exit).__call__"
I didn't need this information ... before I watched this video
I once spent a lot of time trying to implement lazy loading by modifying a class __getattribute__ so that it would initialize the instance and then set the instance __getattribute__ to object.__getattribute__ ... Obviously it did not work, as instance.__getattribute__ is never called, I wish I had known the behavior before, it would have prevented me from loosing a lot of time 😄
yeah making proxy objects is pretty tricky
Any reason why you did `lambda: exit()` instead of just `exit` on the left hand side of `type(exit).__repr__ = ...`?
it's `type(exit).__repr__ = lambda self: exit()` -- need to have a parameter for `self`
@@anthonywritescode ah right, it would work without the lambda because exit does take an argument, but what is passed as self would be taken as an exit-code. Thanks!