# How to evaluate Python custom code in PythonCall?

**URL:** <https://discourse.julialang.org/t/how-to-evaluate-python-custom-code-in-pythoncall/116113>\
**Category:** General Usage\
**Tags:** question, pycall, python, pythoncall\
**Created:** [June 23, 2024, 12:22pm UTC](https://discourse.julialang.org/t/how-to-evaluate-python-custom-code-in-pythoncall/116113 "2024-06-23T12:22:33Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [June 23, 2024, 1:06pm UTC](https://discourse.julialang.org/t/how-to-evaluate-python-custom-code-in-pythoncall/116113/2 "2024-06-23T13:06:58Z")

</div>

See the related topic:

> [@Define Python function in Julia file with PythonCall?](https://discourse.julialang.org/t/define-python-function-in-julia-file-with-pythoncall/98593/7):
>
> Whenever you use pyexec you’re invoking the Python parser, which makes for an unfair comparison. It’s better to use it to create a Python function then call that: @pyexec """ def fib(n): a, b = 0, 1 while a \< n: print(a, end=' ') a, b = b, a+b print() """ =\> fib fib(10) This example uses @pyexec’s handy =\> notation for getting variables into and out of Python.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-evaluate-python-custom-code-in-pythoncall/116113)._
