This document contains additional instructions about how to use this Python project template.
Before starting, make sure you have the following VS Code extensions installed:
- "Python" for general Python support. Extension id
ms-python.python - "Black Formatter" for automatic formatting of Python code. Extension id
ms-python.black-formatter - "Flake8" for linting support for Python files. Extension id
ms-python.flake8
To get an initial virtual environment for your project, perform the following steps:
- Type
Ctrl-Shift-Pand enter "Python: Create Environment...", hit theEnterkey - Choose
Venvfor the "environment tpye" if asked - Choose your installed Python interpreter
- Tick the checkbox for installing the dependencies in
requirements.txt - Wait for the "Creating environment" step to complete
With the first saving of a Python file, you might see a message box saying that "You have the Black formatter extension installed, ...". For this, choose "Yes" to use the automatic code formatting feature.
The full tutorial to get started with Python under VSCode can be found here: https://code.visualstudio.com/docs/python/python-tutorial
You can either handin your source code by submitting something called a Git bundle. The section "Submission via Moodle or other LMS" explains how you can create such a bundle.
Alternatively you can also share your repository with the lecturer.
Please make sure, you check the following points before handing in your solution code:
- Have you included any Python standard libraries in
requirements.txt? Libraries likesys,os,pathlibetc. are already part of the standard Python installation and must not be included in therequirements.txtfile. Please remove them before submission. - Does your project refer to absolute directories? Your colleagues and your lecturer might download your source code into different directories than you did. Make sure, you use project-relative paths when referencing resources in your project, such as pictures or data files.
- Does your README.md still contain text between
<and>? This text is meant as placeholders. Please replace this text including the<and>characters with your own text.
From the root directory of your project run the following git command:
git bundle create <projectname>.bundle --all
Now you can simply upload the newly created file <projectname>.bundle to
Moodle.
Make sure you replace <projectname> in the above examples with a name that
identifies your own project.
Alternatively you can also use the VS Code task "Bundle for Submission" by following these steps:
- Type
Ctrl-Shift-Pand enter "Tasks: Run Tasks", hit theEnterkey - Select the task "Bundle for Submission" and hit the
Enterkey
Now you should find a .bundle file in your project folder that is named
with your project folder name. This can be submitted to Moodle.
Make sure, you create your source code outside of an "ignored" directory.
The folder .vscode, with the exception of a few files, is excluded from
version control with Git. If you place your source code in that folder,
it will not show up in the "Source Control" menu in VSCode. Instead place
it in the main directory or in a new directory.
This folder contains additional settings for VSCode. Amongst them are additional (build-) tasks and settings for code formatting for your project. You can ignore this folder and all contained files for your own projects.