# Encapsulation

say it: **“en-KAP-suh-LAY-shun”** **/ɛnˌkæpsəˈleɪʃən/**

Keeping an object's data behind its methods so it's changed the safe way.

## What is **encapsulation**?

**Encapsulation** means keeping an object's data behind its own methods, so the rest of the program changes it the safe way instead of poking at it directly.

```python
class BankAccount:
    def __init__(self):
        self._balance = 0

    def deposit(self, amount):
        if amount > 0:              # the method guards the data
            self._balance += amount
```

Level: Journeyman · [More Python terms at this level](https://www.ask-codey.com/glossary?category=python&level=3)

Updated: November 17, 2026

## In other subjects

- [Encapsulation in C#](https://www.ask-codey.com/glossary/encapsulation-c-sharp)
- [Encapsulation in Java](https://www.ask-codey.com/glossary/encapsulation-java)
- [Encapsulation in JavaScript](https://www.ask-codey.com/glossary/encapsulation-javascript)
- [Encapsulation in OOP](https://www.ask-codey.com/glossary/encapsulation-oop)

Source: https://www.ask-codey.com/glossary/encapsulation
