Hi, I just saw that it's possible to run python code in RNotebook this is pure amazement!
Are there any plans for code completion?
knitr::opts_chunk$set(echo = TRUE)
library(reticulate)
use_python("/home/myuser/home/myuser/dev/anaconda3/envs/pymachine3/bin/python")
import pandas
##### Please Please Code Completion for python in RNotebooks
flights = pandas.read_csv("~/Downloads/flights.csv") ##### Please Please Code Completion for python!!!
print(flights.head())
2 Likes
I swear I saw a GitHub issue on this a while back, but I can’t seem to find it.
Assuming there is no feature request, I’d encourage you to make one. (Some tips on how best to do that; Writing Good Feature Requests · rstudio/rstudio Wiki · GitHub )
Here’s a discussion about the same feature for Rcpp code chunks from just four months ago,
opened 09:14PM - 25 Mar 18 UTC
enhancement
autocompletion
notebooks
Currently running RStudio daily 1.2.473 on a Mac.
I love the autocomplete fea… ture in cpp files. I would love to see this in Rcpp chunks as well. For instance, in a cpp file I can type:
```
#include <Rcpp.h>
usi
```
and tab completion would pop up `using`. This doesn't happen in Rmarkdown chunks.
I noticed that the newest RStudio daily got support for python autocomplete in _both_ files and chunks, so hopefully this is an easy thing to incorporate!
Thanks as always!
1 Like
jcblum
July 19, 2018, 5:13pm
3
Can’t speak for the issue tracker, but maybe you weren’t imagining things because:
Code completion for Python is coming - you can get it now in the v1.2 preview release of RStudio, or wait until the official 1.2 release is out.
1 Like
Ok I tried 1.2 I see I can do code complete for python inside R but not inside Python snippets
so this get code completion:
```{r setup, include=FALSE}
pandas <- import("pandas")
plt <- import("matplotlib.pyplot")
np <- import("numpy")
t = np$arange(0.1, 2, 0.01)
y <- t^2
.
.
.
```
while this does not get code completion working:
```{python}
flights = pandas.read_csv("~/Downloads/flights.csv")
print(flights.head())
import matplotlib.pyplot as plt
```
I guess that is the supposed to be status in 1.2 thanks!
https://blog.rstudio.com/2018/03/26/reticulate-r-interface-to-python/
1 Like
jcblum
July 19, 2018, 6:55pm
5
Hm, so with 1.2 there is:
But not python code completion in R Markdown python chunks?
1 Like
Autocompletion should work within Python chunks in R Markdown documents:
Can you provide more details on what you're seeing?
3 Likes
uploaded moving gif which shows I have completion with pandas but not for arguments in numpy details in video https://imgur.com/a/Z93fg8x
1 Like
Thanks. This is an issue in reticulate
itself, and we're somewhat handicapped as Python does not provide argument information for builtin functions. See:
opened 05:08PM - 20 Jul 18 UTC
For example:
```r
library(reticulate)
np <- import("numpy")
np$arange(<TAB… >)
```
No completion items are returned. More specifically, this fails to return arguments:
```r
reticulate:::help_formals_handler.python.builtin.object("arange", np)
```
This may ultimately be a limitation of Python. From https://docs.python.org/3.8/library/inspect.html:
> Note Some callables may not be introspectable in certain implementations of Python. For example, in CPython, some built-in functions defined in C provide no metadata about their arguments.
For NumPy functions implemented in native code, we could fall back to parsing the parameter documentation for getting the available arguments.
1 Like