> For the complete documentation index, see [llms.txt](https://docs.arkannis.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.arkannis.net/programming/courses/python-pcap-31-03-course/modules-packages-and-oop/double-under-dunder-methods.md).

# Double Under (Dunder) Methods

## The string Dunder method:

```python
class Employee:
	def __init__(self, name, age):
		self.name = name
		self.age = age
		
	def __str__(self):
		return self.name + " Age is " + str(self.age)
		
tom = Employee("Tom Lanister", 47)
print(tom)
```

* Returns the variables as strings
* Printing: "Tom Lanister Age is 47"

## The len Dunder method:

```python
	def __len__(self):
		return self.age
```

* Returns the len of the variable specified

[Good collection of other Dunder methods](https://www.geeksforgeeks.org/dunder-magic-methods-python/)
