rstudio / rstudio/reticulate

repl_python: how to parse funciton in Rstudio?

Open
#433 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
1.8k
Forks
349
Avg merge
5h 13m
Merged PRs (30d)
4

Description

I am trying to run a python code with a custom-defined function, but running into parsing errors in Rstudio?

  • If I use "run" line by line: it reads only first line of the function?
  • if i select whole function, then click run: result is ok

Also, is there any chance Rstudio would do the indentation correctly within a function? If type "new line", will have 2 spaces instead of the four required?

Thanks!

Try:

library(reticulate)
use_condaenv("py2", conda ='/home/matifou/Programs/anaconda2/bin/conda', required = TRUE)

repl_python()
def helloworld(x):
    print("Hello World "+x)
    print("Hello World again "+x)


helloworld("you")
exit

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported behavior in RStudio with reticulate's repl_python() and the helloworld example from the issue. Compare running the function line by line with selecting the whole function, and check whether new lines inside the function use four-space indentation. Done means both parsing and indentation behave correctly for this example.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, r
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.