# Decorators

## @property

Makes a function works like some variable.&#x20;

```python
class House():

@property
def temperature(self):
    return self._temperature*10

@temperature.setter
def temperature(self, temp):
    self._temprature = some_func(temp)
    
#use this as

house = House()
temp = house.temperature
house.temperature = 50.0
```

{% embed url="<https://www.programiz.com/python-programming/property>" %}

{% embed url="<https://www.freecodecamp.org/news/python-property-decorator/>" %}

## @classmethod and @staticmethod

```python
# Python program to demonstrate  
# use of a class method and static method. 
from datetime import date 
  
class Person: 
    def __init__(self, name, age): 
        self.name = name 
        self.age = age 
      
    # a class method to create a  
    # Person object by birth year. 
    @classmethod
    def fromBirthYear(cls, name, year): 
        return cls(name, date.today().year - year) 
      
    # a static method to check if a 
    # Person is adult or not. 
    @staticmethod
    def isAdult(age): 
        return age > 18
  
person1 = Person('mayank', 21) 
person2 = Person.fromBirthYear('mayank', 1996) 
  
print (person1.age) 
print (person2.age) 
  
# print the result 
print (Person.isAdult(22)) 
```

See how you can create class instance through some other logic using `@classmethod.`

{% embed url="<https://stackabuse.com/pythons-classmethod-and-staticmethod-explained/>" %}


---

# 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://theshank.gitbook.io/ai/python-tricks-and-tips/concepts.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.
