These are shortcuts that you can use with VSCode. Most of these notes are taken from “Python Data Science Handbook” and converted to VSCode.
Ctrl
+Space
You can use Ctrl
+Space
for autocompletion and exploration of the contents of objects, modules, and namespaces.
Every Python object has various attributes and methods associated with it. For example, to see a list of all available attributes of an object, you can type the name of the object followed by a period (.
) character and press Ctrl
+Space
.
Example:
1 | |
2 | |
You can also narrow down the list by typing the first character or several characters of the name, and VSCode will filter the matching attributes and methods.
1 | |
2 | |
Ctrl
+Space
with importsCtrl
+Space
is also useful when importing objects from packages.
1 | |
If that does not work, then type the first letter of an object that you want to import and then when you press Ctrl
+Space
it should show all the matching objects. You can then delete the first letter and you should see all the available objects that can be imported.
You can type c
, for example, to find all possible imports in the itertools
package that start with c
:
1 | |
Similarly, you can use Ctrl
+Space
to see which imports are available on your system (this will change depending on which third-party scripts and modules are visible to your Python session):
1 | |
Or filter by the first letter:
1 | |
Example: Enter len?
and run the cell.
Enter the name of the code whose source code you want to access and run the cell.
Example: my_function??
This is how you would run the ls
command, for example, in VSCode: Enter !ls
and run the cell.
You may not need to use the ls
command too often since VSCode has a built-in File Explorer, but that is a simple command line example.