Skip to Content
Daniel Arbuckle's Mastering Python
book

Daniel Arbuckle's Mastering Python

by Daniel Arbuckle
June 2017
Beginner to intermediate
274 pages
6h 49m
English
Packt Publishing
Content preview from Daniel Arbuckle's Mastering Python

Making a package executable via Python -m

In the previous chapter, we ran command-line tools, such as doctest and venv, by typing in the python3 -m command followed by the name of the tool we wanted it to run:

What were we actually asking Python to do when we did that?

The -m command-line switch for Python tells it to run a module. It uses the same mechanism to find the module that it would if we'd used an import statement with the module's name and then it executes it.

However, venv isn't a module, it's a package. So, what's happening when we use python -m venv? We gave Python a package name, but we didn't give it a module name inside the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Deep Learning for Games

Hands-On Deep Learning for Games

Micheal Lanham
Mastering PyCharm

Mastering PyCharm

Nafiul Islam
Python: Journey from Novice to Expert

Python: Journey from Novice to Expert

Fabrizio Romano, Dusty Phillips, Rick van Hattem

Publisher Resources

ISBN: 9781787283695Supplemental Content