AI engineering glossary · Python advanced

What is __call__?

__call__: The special method that lets an object be called like a function using parentheses. It is useful for objects that carry state between calls, such as configured models or decorators implemented as classes.

Level: advancedTopic: Python advanced

__call__: an example

class Scale: def __call__(self, x): return x * self.k; double = Scale(2); double(5) returns 10.

Related terms

More Python advanced terms

Where you learn it

__call__ is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.