> For the complete documentation index, see [llms.txt](https://openai.gitbook.io/code-cheatsheets/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://openai.gitbook.io/code-cheatsheets/all/python/classes.md).

# Classes

```python
class Person:
    def __init__(self, firstName, lastName): #constructor
        self.firstName = firstName
        self.lastName = lastName

    def __repr__(self): #how it is printed
        return self.firstName + " " + self.lastName
    
    def __del__(self): #run when last reference to it goes out of scope
        print self.id, 'died'
       
class Employee(Person):
    def __init__(self, firstName, lastName, weekly_salary):
        super().__init__(firstName, lastName)
        self.weekly_salary = weekly_salary

    def calculate_payroll(self):
        return self.weekly_salary
```

No private variables, `self._x` just indicates private not enforced

## Usage

```python
me = Person('Jorge', 'Fuentes')
```
