Importing sys in Python: What the import statement really does

Importing sys in Python: What the import statement really does

“sys” is where Python keeps vital info about its runtime environment.

So why import it?

Not to load it; sys is loaded when Python starts.

Rather, the import just defines “sys” as a global variable.

Importing “sys” takes almost no time, and provides useful info.