+ 10
Using __ipow__ in Python
I've been experimenting with Python Magic Methods and I came across __ipow__ So __pow__ can specify a 3rd argument which lets you do a**b%c efficiently by using an inbuilt pow(a,b,c) function. Without the c, you can just do a**b or pow(a,b). Similarly, for __ipow__, you use a**=b but what is the 3 argument equivalent? I've tried searching online to get no clear answer. Can someone help me in finding how to use the __ipow__ magic method with 3 arguments? Thanks!
4 Answers
+ 12
+ 9
The __i...__ methods are only implemented for mutable data types like lists because they are not returning a new object but are changing the original one. Thus having a modulo doesn't make any sense. I can't imagine how to modulo a list for example. So yes, that parameter seems to be pretty useless.
+ 6
Kuba Siekierzyński Sorry for pinging you but I feel that you might have an insight into this question, so if possible could you help me?
+ 4
Николай Шаповаленко so it means that it is useless?