Interview Prep/Python for DevOps/Language essentials & functions

What are keyword-only and positional-only parameters?

IntermediateConceptLanguage essentials & functions
Answer

Parameters after a bare * must be passed by keyword; parameters before / must be passed positionally.

def scale(deployment, replicas, /, *, namespace="default", dry_run=False): ...
scale("api", 3, dry_run=True)        # ok
scale("api", 3, True)                 # TypeError

We make destructive flags like dry_run and force keyword-only so nobody can accidentally pass True in the wrong position.

All Python for DevOps questions Roadmap: Python for automation

More on Language essentials & functions