+ 2

What is dunders in programming world? What it's used?

15th Oct 2019, 9:14 PM
Prince Raj
Prince Raj - avatar
5 odpowiedzi
+ 9
If i should add this. They are called magic methods because they mostly used for operator overloading without explicit conversion. P.S: probably nothing magical true or perhaps coz they can be confusing
15th Oct 2019, 10:53 PM
BlackRose Mike
BlackRose Mike - avatar
+ 5
Mirielle🐶 thanks for the useful info. I had no idea.
15th Oct 2019, 9:33 PM
Sonic
Sonic - avatar
+ 2
simple example/explanation.. imagine you had a class rectangle with an appropriate constructor...so rect1 = rectangle(10, 20) rect2 = rectangle(30, 40). You could define a dunder to do:- rect3 = rect1 + rect2. (it is explained in the python tutorial)
15th Oct 2019, 9:58 PM
rodwynnejones
rodwynnejones - avatar
+ 2
Here’s an example of how magic methods are used for operator overloading in Python. https://code.sololearn.com/c54jn2y004wp/?ref=app
16th Oct 2019, 2:29 AM
Rora