> For the complete documentation index, see [llms.txt](https://igor-19.gitbook.io/qa/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://igor-19.gitbook.io/qa/avtomatizaciya-testirovaniya/python/oop-v-python-vo-vsekh-podrobnostyakh/no-data-descriptor.md).

# No Data Descriptor

**Геттер** (`__get__()`) с аргументами:

* *instance* = экземпляр класса с которого происходит обращение к свойству
* *owner\_class* = класс собственник

```python
from time import time

class Epoch:
	# intance - экземпляр класса с которого происходит обращение к свойству
	# owner_class - класс собственник
	def __get__(self, instance, owner_class):
		return int(time())

class MyTime:
	epoch = Epoch()

m = MyTime()

print(m.epoch)
# 15984124424 - время в секундах
123456789101112131415
```

Можно использовать и обычный геттер на `@property` но в таком случае, будет возникать много повторяемого кода...

```python
from random import choice


class Game:
	@property
	def rock_paper_scissors(self):
		return choice(["Rock", "Paper", "Scissors"])

	@property
	def dice(self):
		return choice(range(1, 7))

	@property
	def flip(self):
		return choice(["Head", "Tails"])

g = Game()

print(g.flip)
# Tails
...
123456789101112131415161718192021
```

В этом случае поможет определение отдельного класса (*No Data Descriptor*) на основе дандер метода `__get__ ()`

```python
from random import choice


class Choise:
	# * - принимает любые аргументы и упаковывает их в список
	def __init__(self, *choice):
		self._choice = choice

	def __get__(self, instance, owner_class):
		return choice(self._choice)


class Game:
    dice = ChoiceGame(1, 2, 3, 4, 5, 6)
    flip = ChoiceGame("Head", "Tails")
    rock_paper_scissors = ChoiceGame("Rock", "Paper", "Scissors")

g = Game()

print(g.flip)
# Tails
...
```
