# Convert a Python function with decorator to Julia

**URL:** <https://discourse.julialang.org/t/convert-a-python-function-with-decorator-to-julia/101575>\
**Category:** General Usage\
**Created:** [July 13, 2023, 1:39pm UTC](https://discourse.julialang.org/t/convert-a-python-function-with-decorator-to-julia/101575 "2023-07-13T13:39:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![FemtoTrader](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/femtotrader/32/309_2.png) [@FemtoTrader](https://discourse.julialang.org/u/FemtoTrader)\
**Post date:** [July 13, 2023, 1:39pm UTC](https://discourse.julialang.org/t/convert-a-python-function-with-decorator-to-julia/101575/1 "2023-07-13T13:39:24Z")

</div>

Hello,

I wonder what is the more Julia-nesque approach to convert a Python function with decorator such as

```python
@schedule(interval="5m", symbol="SYMBOL", window_size=150)
def run_5m(state, data):
    print("I'm running once every five minutes")

```

Kind regards

---

<div class="post-metadata">

**Author:** ![Alexander\_Knudson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexander_knudson/32/215656_2.png) [@Alexander\_Knudson](https://discourse.julialang.org/u/Alexander_Knudson)\
**Post date:** [July 13, 2023, 2:06pm UTC](https://discourse.julialang.org/t/convert-a-python-function-with-decorator-to-julia/101575/2 "2023-07-13T14:06:23Z")

</div>

I think you might want the `Timer` method/type, which you can read about here: [Essentials · The Julia Language](https://docs.julialang.org/en/v1/base/base/#Base.Timer-Tuple%7BFunction,%20Real%7D)

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [July 13, 2023, 2:47pm UTC](https://discourse.julialang.org/t/convert-a-python-function-with-decorator-to-julia/101575/3 "2023-07-13T14:47:45Z")

</div>

If the question is less about this specific decorator and more about decorators in general, the answer is that [metaprogramming with macros](https://docs.julialang.org/en/v1/manual/metaprogramming/#man-macros) is the closest correspondence. However, depending on what the decorator does, there may be opportunities to implement the functionality with multiple dispatch or higher order functions, without invoking metaprogramming.
