Skip to Content
Course content

Functions, Arguments & Modules

Functions are the unit of reuse in Python — and the building blocks of every Odoo model method you will write later.

Key topics

  • def, parameters vs arguments, return values, multiple returns, early returns.
  • Positional, keyword, default, *args and **kwargs; keyword-only arguments.
  • Scope: local vs global, the LEGB rule, why globals are avoided.
  • Lambda expressions and the key functions sorted(), min(), max(), filter(), map().
  • Modules and imports: import, from ... import, __name__, the standard library tour (datetime, json, csv, os, sys).
  • Docstrings and type hints as documentation habits.

Exercise / deliverable

Create a module text_utils.py with slugify(text), word_count(text) and censor(text, *words); import it from main.py and demo each function with printed output.

Level: Beginner | Duration: ~0.5h. Defining functions, every argument flavor, return values, lambda expressions, and organizing code into modules.
Rating
0 0

There are no comments for now.