I am currently working on a VSCode extension, and I would like to utilize the abilities of Intellisense (Pylance in this case) to help with a feature in my extension. I simply want to capture the output of Pylance so I can pass it as an argument into a VSCode extension function. I am unsure how it would be possible to capture Intellisense output. Another interesting question would be whether it is possible to alter Intellisense output directly: could you adjust how Intellisense is displayed with a VSCode extension?
In short: Is it possible to capture Intellisense output and/or alter Intellisense output is displayed using a VSCode extension?
Related
I wanted to give VSC a try for developing some Python programs, where I only used PyCharm before. One of the most helpful features for me in Pycharm was the PyDev Console, where I can quickly try small snippets of code (think 3-10 lines), and adjust it to work the way I want it to.
I see VSC has a console, but it's much more like the regular IDLE console, where it's kind of hard to write these snippets of code (fixing something 2 lines prior for example is pretty much impossible).
I've been searching for an extension that'll give me a PyCharm-like console experience in VSC, but have been unable to find one. Is is out there? Or is there another way to get to the same result (like setting up a custom console based on the same PyDev console)?
Have you tried Jupyter Notebook and Interactive? There are provided by the Jupyter Extension which is bound with Python Extension.
Open the Command Palette (Ctrl+Shift+P), with the command of:
Jupyter: Create New Blank Notebook
Jupyter: Create Interactive Window
You can refer to the official docs for more details.
In vscode, when I hover on a python keyword, a tooltip showing the definition of the keyword appear.
I also have pylint installed, and I want to keep the tooltip for showing pylint error but disable it for the python keyword definition. Is there any way to do that ?
By setting the language service to Microsoft in the settings.json file of vscode, the definition of python keywords disappear.
It does not really answer the question I asked, but it is enough for my needs.
I am more used to Spyder and very new in vsc. In Spyder you have a python console where you can quickly try a codesnipped like:
print(len(a))
without having to run the entire code.
Is that also possible in vsc? I have not seen anything.
In addition, I can only see the variables in the debug mode. In Spyder I have all variables after one run at hand and can try and experiment on the fly with them. Is there another Variable-viewer plugin or how could that be enabled?
You can use this extensions of python. It has a Jupyter Notebook feature that comes with a variable explorer. It is recommended to also add the Jupyter extension as well (they work together just fine), you can find it here.
You can read this documentary about how to use Jupyter with visual studio code, you can see that it shows how to display the variables the way you wanted.
I'm new to python in visual studio..I'm trying to have the same environment of sublime text.
I configured everything auto-formatting , auto-completion etc...
But when I write essential keyword like "self", the tool doesn't suggest me the keyword
So if I write "s" in sublime I obtain a suggest for "self".
But this don't happen in visual studio.
Is it normal? what can i do?
PTVS will only use autocomplete functionality in certain scenarios. In order for 'self' to display after typing 's' you will need to press CTR+SPACE or CTR+J. These are the default commands for autocomplete. You can learn more at the completion page of the wiki.
Here's an excerpt:
Completions can be shown at any time by pressing Ctrl+J or Ctrl+Space, or may be triggered automatically by certain commands (such as import), operators (such as a period/full stop), or by typing at any place where completions are likely to be helpful.
I often use R to analyze data, and really enjoy Notepad++ along with NppToR. Especially, NppToR enables to run a part of code without much hassle. I just highlight a snippet of R code to run and press F8. Then the code magically runs in R console.
Now, I am required to use python to analyze data. I know that ipython is great to work interactively, but it is always very annoying to copy a snippet of python code and manually paste that into ipython console. Also, indentation is often mixed and thus the entire lines are failed to run. Note that I want to run 'selected' lines of codes, not the entire file.
So I am looking for a program/plugin/macro similar to NppToR, but working with python/ipython console. I have searched the web, but couldn't find such one. Some plugins are nice, but not exactly what I want. For example, Python Script enables extending Notepad++ itself, but not outside. Various other 'Run' extensions enables the entire file to be run in python.
You can customize the editor IPython uses for the edit command, and configure IPython to use Notepad++. IPython 0.11 creates a .ipython/profile_default folder in your user folder (in my case C:/Users/zk/.ipython/profile_default). To configure IPython to use Notepad++ create .ipython/profile_default/ipython_config.py with the following:
c = get_config()
# use DOS style path, C:/PROGRA~2 on my 64-bit system points to C:/Program Files (x86)
c.TerminalInteractiveShell.editor = 'C:\PROGRA~2\NOTEPA~1\NOTEPA~1.exe'
# set editor for Qt Console, if you wish to use that
c.IPythonWidget.editor = 'C:\PROGRA~2\NOTEPA~1\NOTEPA~1.exe'
You can then start up IPython and use the edit command to run Notepad++ from IPython, saving and closing Notepad++ will execute the file in IPython.
If you don't mind installing PyQt4 and pyzmq (and I believe pygments, at least for IPython 0.12-dev), IPython's Qt console works really well (frankly the nicest interactive environment you can get for Python). You can paste directly into IPython and it'll adjust indentation for you (shifting over padded code).