Using Python's -m Flag for Modules | Generated by AI

Home 2025.10

Yes, -m means run a module as a script. Let’s break this down with your examples:

python -m unittest

This tells Python:

python -m pip

This is the same pattern:

Difference from python test_xx.py

When you do:

python test_xx.py

you are running that specific file directly, not using unittest’s test discovery or runner.


Summary:

Would you like me to also show you how pytest handles this differently, since you might compare unittest vs pytest?


Back

openai/gpt-5

Donate