VSCode & Python


Starting a New Python Project in VSCode 


Python commands in the terminal when multiple versions of Python are installed


In Python, "python" and "python3" are both command-line commands used to run Python code, but they have a few key differences:

In summary, "python" and "python3" both allow you to run Python code, but "python" is used to run the default version of Python on a system, while "python3" is used to run a specific version of Python 3.x. On Windows, "py" can be used instead of "python" to run python.


Running Python Modules


In Python, the "-m" command is used to run a module as a script. It allows you to run a python module by specifying the module name, rather than the name of the script file.

For example, if you have a module named "mymodule" in your python environment, you can run it by using the command: python -m mymodule

This is equivalent to running a script named mymodule.py with the command: python mymodule.py

The -m command also allows you to run built-in modules that come with python, for example: python -m venv myenv 

This command creates a new virtual environment in the folder myenv.

Another example is using the -m http.server command, this command starts a simple HTTP server in the current directory.

This feature is particularly useful when you have a module that you want to run as a script but don't want to create a separate script file. It also allows you to run built-in modules as script, which can be useful in various scenarios.



Created with the assistance of OpenAI's ChatGPT