Introduction to Python

Project: Introduction to Python (1)

Prof. Dr. Gerit Wagner
Introduction to Python

Project: Groups, forks and setup

  • Groups formed in the issue feeds
  • Forks were created.
  • Further questions related to GitHub or the setup?
Prof. Dr. Gerit Wagner
Introduction to Python

Learning objectives:

  • Familiarize with Python syntax
  • Learn good debugging and development practices
  • Understand how to extend a Python package (CoLRev)

Groups

  • Form groups of three to four, solve the tasks together, and discuss your solutions.
Prof. Dr. Gerit Wagner
Introduction to Python

Start the Codespace

Open the notebook for practicing Python.

Start the Codespace in the tutorial_python branch of the CoLRev upstream repository.

The setup can run in the background, while we focus on the concepts.

Prof. Dr. Gerit Wagner
Introduction to Python

Python

  • Supports multiple paradigms: object-oriented, procedural, or functional
  • Python is an interpreted language: no need to compile (build jars) before running
  • Uses indentation instead of brackets to separate blocks (such as if statements)
  • Is strongly, dynamically typed
  • Provides access to many packages on PyPI, covering machine learning, data science, web scraping, etc.
  • Python is actively developed, with new versions introducing changes in functionality and old versions no longer receiving security updates
Prof. Dr. Gerit Wagner
Introduction to Python

What we will learn in the Python session(s)

center

Prof. Dr. Gerit Wagner
Introduction to Python

Writing and running Python code

center

Prof. Dr. Gerit Wagner
Introduction to Python

Python packages

center

Prof. Dr. Gerit Wagner
Introduction to Python

Best practices

  • Carefully read tutorials, vignettes, and code examples (e.g., on GitHub)
  • Start with small code segments, try whether they work, and extend them
  • Add or commit working code frequently
  • Use code linters to ensure high code quality (run pre-commit run --all)
  • To debug code, check whether variables have the expected values (use assert or print statements)
  • When exceptions are thrown, read the Traceback:

center

Prof. Dr. Gerit Wagner
Introduction to Python

Next steps

  • Read the package development documentation.
  • Study code of related CoLRev packages.
  • Take notes on the CoLRev-objects or libraries that will be needed.

Note: These tutorials may be helpful to continue practicing Python

Prof. Dr. Gerit Wagner
Introduction to Python

We value your feedback and suggestions

We encourage you to share your feedback and suggestions on this slide deck:

Edit Suggest specific changes by directly modifying the content
New Issue Provide feedback by submitting an issue

Your feedback plays a crucial role in helping us align with our core goals of impact in research, teaching, and practice. By contributing your suggestions, you help us further our commitment to rigor, openness and participation. Together, we can continuously enhance our work by contributing to continuous learning and collaboration across our community.

Visit this page to learn more about our goals: 🚀 🛠️ ♻️ 🙏 🧑‍🎓️ .

Prof. Dr. Gerit Wagner

[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?repo=digital-work-lab/practice-python)

--- For the tutorial, we switch to the `tutorial_2024_04` branch: ``` git clone https://github.com/CoLRev-Environment/colrev cd colrev pip install -e .[dev] git fetch git checkout tutorial_2024_04 git reset --hard ca9902e666518af1d33a368adf055c9809004433 ``` - As the session progresses, you can checkout the current commits. - Whenever you see a `git reset --hard ...` command on the following slides, you can use it to set your repository to the required state (commit).