AI engineering glossary · Python advanced

What is encapsulation?

Encapsulation: Bundling data with the methods that use it and limiting direct outside access to the internals. It protects an object's state from accidental misuse and lets the internal design change without breaking users of the class.

Level: intermediateTopic: Python advanced

Encapsulation: an example

A BankAccount keeps _balance internal and exposes deposit() and withdraw(), which check that the amount is valid.

Related terms

More Python advanced terms

Where you learn it

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