---
title: "What are Python decorators?"  
description: "What are Python decorators?"  
author: "Ravi Vishwakarma"  
published: 2025-08-26  
updated: 2025-08-26  
canonical: https://www.mindstick.com/interview/34360/what-are-python-decorators  
category: "python"  
tags: ["python-3.4", "python", "Python 3"]  
reading_time: 1 minute  

---

# What are Python decorators?

A [**decorator**](https://www.mindstick.com/forum/161519/what-are-decorators-in-python) is a function that modifies the behavior of [another function](https://www.mindstick.com/forum/161503/what-are-python-decorators-and-how-are-they-used-in-real-world-ml-ai-projects) or class without changing its code.

```python
def decorator(func_name):
    def wrapper_fun():
        print("Before function call")
        func_name()
        print("After function call")
    return wrapper_fun

@decorator
def say_hello():
    print("Hello!")

say_hello()
```

## Output:

```plaintext
Before function call
Hello!
After function call
```

## Answers

### Answer by Ravi Vishwakarma

A [**decorator**](https://www.mindstick.com/forum/161519/what-are-decorators-in-python) is a function that modifies the behavior of [another function](https://www.mindstick.com/forum/161503/what-are-python-decorators-and-how-are-they-used-in-real-world-ml-ai-projects) or class without changing its code.

```python
def decorator(func_name):
    def wrapper_fun():
        print("Before function call")
        func_name()
        print("After function call")
    return wrapper_fun

@decorator
def say_hello():
    print("Hello!")

say_hello()
```

## Output:

```plaintext
Before function call
Hello!
After function call
```


---

Original Source: https://www.mindstick.com/interview/34360/what-are-python-decorators

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
