First, you will need to download an IDE such as VS Code, IntelliJ PyCharm or Idea, etc. If you are given the option to add to path, do it. Restarting the terminal may be needed for the change to propagate. For VS Code, install the suggested plug-ins such as PyLance.
Alternatively, just open your IDE and open the project folder through the GUI. The below is more convenient once you set it up and learn it.
cd, drag and drop the folder in which the project is (tested with Windows Terminal).
_your_editor_ ., i.e.
code .(run program aliased as code in the folder ".", which is the current directory).
code .) and IntelliJ (
pycharm .) editors. See the Using an IDE section for features you might want to use.
vi file.py. Note that you can press tab to get help from autocomplete instead of typing out file names, it'll look through the possibilities and give as many characters as unambiguous.
Cmd-Tabto switch between windows.
I use VS Code (on Windows, but shortcuts should be the same), so specific directions & shortcuts are for that IDE, but most IDE's should have the same features, so you can look up how to do it in yours. You should try these out in the python basics or the tutorial project; this can save you a lot of time in the future projects.
These are in rough order of usefulness.
mouse hoverto see what a variable is,
Ctrl- mouse hoverto see stringdoc or definition,
Ctrl- mouse clickor
f12to navigate to definition. Especially helpful for functions, although the IDE may not always figure out the definitions, for instance when PyLance in VS Code can't figure out what class's method is getting called.
Ctrl-Shift-F. If you want to find what function
foodoes, search for
Ctrl-`(the symbol to the left of 1).
python -V(note the capital V) to check that the Python version is 3.6.
f5. Select Python, make sure your Python 3.6 interpreter is in use, choose "current python file".
Alt-Tabon Windows and Linux or
Cmd-Tabon MacOS. Pressing tab more than once chooses a less recent window.
Ctrl-Tto open new tab,
Ctrl-Shift-Tto re-open the most recently closed tab (repeatable),
Ctrl-Wto close the current tab,
Ctrl-Shift-Tabto cycle between tabs (Firefox and Chrome are different with this last one).
This is not related to course content or the workflow at all.
The OS has many executable files, and it needs the path to the executable to run it. For instance, clicking an icon in program list or taskbar/ dock is just a shortcut -- mapping from program name to the location of the file to execute. From the terminal, we can simply navigate into the folder of the executable and run the file, or give the absolute path to the file.
In the terminal, a command consists of first the program, then its options and arguments. If the program part doesn't have any "/" in it, it is recognized as an attempt to use the Path environment variable.
Path is conceptually a collection of shortcuts for commands. The OS looks for the first word as an executable in the folders given in the Path variable. We simply need to add the folder containing the appropriate program to Path if we want to call if from anywhere.
Anaconda effectively changes what
python corresponds to, pointing it to a different Python interpreter. Furthermore, it keeps that Python interpreter and its installed libraries separate from everything else, all without breaking the Path variable.
Written by: Evgeny Pobachienko