AI engineering glossary · Python advanced

What is constructor?

Constructor: The code path that builds and prepares a new object when you call a class. In Python this is the class call itself, which runs __new__ to allocate the object and then __init__ to fill in its initial state.

Level: beginnerTopic: Python advanced

Constructor: an example

Calling Model('resnet', layers=50) constructs a Model object whose __init__ stores the name and layer count.

Related terms

More Python advanced terms

Where you learn it

Constructor 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.