4 ms·
I am having some problems with magic methods in Python. They are defined inside a class using built-in functions and are not directly callable. What are some he
by pythonscheme 10y ago
I am having some problems with magic methods in Python. They are defined inside a class using built-in functions and are not directly callable. What are some helpful resources with this topic? Thanks.
- _RPM 10y agoThe Python docs are high quality.
- ivank 10y agohttp://www.rafekettler.com/magicmethods.html#appendix1 http://www.rafekettler.com/magicmethods.html#appendix1 and you can call them directly: >>> (3).__neg__() -3
- pramodliv1 10y agoHere's my beginner-friendly article on magic methods: https://conceptcoaster.com/course/python-tutorial/magic-methods-and-protocols/ https://conceptcoaster.com/course/python-tutorial/magic-meth... If you have any trouble understanding it, go to the homepage: https://conceptcoaster.com/course/python-tutorial/ https://conceptcoaster.com/course/python-tutorial/ and work your way to magic methods.
- ams6110 10y agoWord to the wise: avoid anything "magic" when writing code.
- thrownaway1984 10y agoWord to the wise. Better to stay silent and for people to think you stupid than to open your mouth and have them know for sure. Python magic methods are not "magic" but are a very standard part of the language and are well documented.
- ZanyProgrammer 10y agoAnd you wonder why some people never catch onto programming.