R

Ram Sharma • 3.40K Points
Extraordinary

Q. What will be the result?

Code:
class X:
def __call__(self):
return 'Called'

x = X()
print(x())
  • (A) Error
  • (B) None
  • (C) Called
  • (D) Function
  • Correct Answer - Option(C)
  • Views: 17
  • Filed under category Python
  • Hashtags:

Explanation by: Ram Sharma
The `__call__` method makes an object callable like a function.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.