2024-heraklion-ODD/exercises/Exercise 2b Unprotected code.md

662 B

Exercise 2a: Unprotected code

Goal

Investigate what happens when importing from modules with "unprotected" code.

Preparation

(none)

Tasks

  1. Create a file in the src/ folder called main.py.

  2. Add a line in main.py that imports the make_example_potion function from make_potion.py.

  3. BEFORE YOU EXECUTE THE FILE. Discuss with your partner what you think will happen when you run main.py.

  4. Run main.py. Does your prediction match reality?

  5. (optional, for those who know) Discuss with your partner:

    • Why did this behaviour occur?
    • Why is it not good?
    • What can you do to "fix" the behaviour?