0

I am currently studying the methods for each built-in function, many apply to other functions. I came across 2 methods withing the bool() function: x.__lshift__ and x.__pow__. Now, x.__lshift__(y) equates to x<<y while x.__pow__(y[, z]) equates to pow(x, y[, z]).

My Question: These two methods appear to be almost the same ( I used them within the shell to check, if this question seems to be not thought out I probably used them incorrectly), What is the difference, usage with bool(), between the two?

TimLayne
  • 124
  • 2
  • 13

1 Answers1

1

In python, you are allowed to overload operators by overriding some special member methods. You can change the behavior of << operator by overriding lshift. This is the same to other operators and their corresponding functions.

See this:operator overloading in python

Community
  • 1
  • 1
TwilightSun
  • 2,275
  • 2
  • 18
  • 27