'Indentation issue when defining python functions in the console of Rstudio using reticulate::repl_python()
I am using Rstudio (2022.02.2 Build 485) and reticulate::repl_python() to run Python (3.10), see link.
The problem is that the console does not seem to deal with defining functions properly:
>>> for i in globals().keys():
... if not i.startswith('_'):
... exec('del ' + i)
...
>>> def excel_to_pandas(URL, local_path):
... resp = requests.get(URL)
... with open(local_path, 'wb') as output:
... output.write(resp.content)
... df = pd.read_excel(local_path)
... return df
...
...
... print(excel_to_pandas(url_area, os. getcwd()))
...
It acts like the function is unfinished. They run fine when running from script. Does anyone have an idea what causes this and how this issue can be circumvented?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
