13  :blue_book: Use Python within Quarto

13.1 Python code chunks

Warning

This section is for (advanced) Python/R Markdown users only

You still need to import the R package reticulate if you want to use the Knitr engine and manipulate Python objects within R code chunks.

```{r}
library(reticulate)
```

13.1.1 Call R objects in Python code chunks

R objects can be manipulated in Python code chunks by referring to them as r.

```{r}
val <- 10
```
```{python}
val = 5
print(r.val)
```
10.0

13.1.2 Call Python objects in R code chunks

Python objects can be manipulated in R code chunks by referring to them as py$

```{r}
print(val)
print(py$val)
```
[1] 10
[1] 5