How#

How to navigate directories in the command line#

In the command line the cd command (short for “change directory”) can be used to enter a given directory.

Tip

$ cd directory

Attention

The target directory must be contained in the directory you are currently in.

For example to change directory in to a directory called cfm:

% cd cfm

To go back to the previous directory use ..:

$ cd ..

How to create a new directory in the command line#

In the command line the mkdir command (short for “make directory) can be used to create a new directory.

Tip

$ mkdir directory

For example to create a director called scripts:

$ mkdir scripts

How to see the contents of a directory in the command line#

In the command line we can see the contents of the current directory:

  • On Windows using dir

  • On OS X using ls

Tip

How to run python code in a file#

To run code in a file we type python followed by the name of the file in the command line.

Tip

$ python file.py

For example to run code in a file called main.py:

$ python main.py

How to run python code without using a file or Jupyter#

In the command line if you type python without passing a filename this will create a prompt in which you can directly write Python code.

Tip

$ python

When doing this, we see a prompt appear with >>>, we can directly type python code in there and press enter:

>>> 2 + 2
4

Attention

This interface to Python is called a Read-Eval-Print-Loop and is often referred to as a REPL.

Using python is the simplest of REPLs, there are others (for example ipython).

Attention

This interface to Python is quite limited and should only be used for quick access to Python as a way to run simple commands.

How to install VScode plugins#

VScode is a powerful editor with a number of plugins for different languages and functionalities.

To install a particular plugin in the menu bar, click on Code > Preferences > Extensions.

From there you can search for a specific plugin and install it by clicking on the install button.

Click the toggle (“Click to Show”) to see a demo of this: