0
Is this example for explaining rtruediv ?
In anyway to interpret it seems trudiv method is working well.
2 odpowiedzi
0
I just added an exception: When the left side does not have an action (it fails) Python tries the right side.
This could be used for interesting responses to input / data files / types without needing a try...catch.
the exception here is
() /x
Tuple does not know how to divide itself by 5 (x's integer value) so it asks x to handle it.
+ 3
I'm not 100% sure what you are asking, so I asked a question of myself:
"why would I use rtruediv?"
Here's a code that produces a custom integer division (how many balls do you get?) if a special type of integer is on the right hand side
https://code.sololearn.com/ceY9R1IZuGKr/?ref=app
There is an explanation of how __rtruediv is activated on StackOverflow:
https://stackoverflow.com/questions/37310077/JUMP_LINK__&&__python__&&__JUMP_LINK-rtruediv-does-not-work-as-i-expect
Basically, the right-hand side must be a *subclass* of the left-hand side for this to work.