# В чем отличие вызова функции с скобками и без?

### **1. С скобками `()`**

* Когда вы пишете `func()`, функция **выполняется сразу**.
* Возвращается **результат выполнения функции**.

```python
def greet():
    print("Hello!")
    return 42

result = greet()  # функция вызывается
print(result)     # 42
```

**Вывод:**

```
Hello!
42
```

***

### **2. Без скобок**

* Когда вы пишете `func`, вы **не вызываете функцию**, а **получаете сам объект функции**.
* Можно присвоить переменной, передать как аргумент, хранить в списке.

```python
def greet():
    print("Hello!")

f = greet  # ссылка на функцию
f()        # вызов функции через переменную
```

**Вывод:**

```
Hello!
```

* Это удобно для **декораторов, callback-функций, хранения функций в структурах данных**.

```python
funcs = [greet, lambda: print("Hi")]
for f in funcs:
    f()  # вызов каждой функции
```

***

### **3. Важные моменты**

| Синтаксис | Что происходит                           | Пример использования                            |
| --------- | ---------------------------------------- | ----------------------------------------------- |
| `func()`  | Функция вызывается, возвращает результат | Вызов функции в тесте, обработка результата API |
| `func`    | Получаем объект функции                  | Передача в декоратор, callback, список функций  |

***

💡 **Пример в автотестах:**

```python
def check_login():
    return True

# Ссылка на функцию для pytest fixture
test_funcs = [check_login]  # без скобок
for func in test_funcs:
    assert func()  # вызов функции с скобками
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kaze.gitbook.io/qa-theory/osnovy-programmirovaniya-na-python/v-chem-otlichie-vyzova-funkcii-s-skobkami-i-bez.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
