iTayb
iTayb

Reputation: 12743

the _subprocess module

There is a module called _subprocess, as seen in that question.

I was able to import it, but I haven't found any documentation about what is it and how it is different from subprocess.

Anybody here know what this module does?

Upvotes: 3

Views: 1480

Answers (3)

yak
yak

Reputation: 9041

As with other names in Python starting with an underscore, such modules are usualy not meant to be used directly. Usually there is a module without the underscore that should be used instead, as is the case with subprocess.

This is often used to divide module implementation into parts coded in C and pure Python. The underscored module is written in C and a pure Python module is added "on top of it" to provide a high level API.

Upvotes: 2

Danica
Danica

Reputation: 28856

_subprocess seems to be a Windows-specific C extension module that implements some of the functionality that's used by the subprocess module proper. If you look in the source for subprocess, _subprocess is only referred to inside of if mswindows blocks.

It's a detail of the implementation, and so you definitely shouldn't use it in any actual code (though of course some curiosity is never a bad thing).

Here's the source for `_subprocess'. The comment at the top says

* support routines for subprocess module
*
* Currently, this extension module is only required when using the
* subprocess module on Windows, but in the future, stubs for other
* platforms might be added here as well.

Upvotes: 4

Gareth McCaughan
Gareth McCaughan

Reputation: 19981

It's an implementation detail, present on Windows but not (e.g.) on Unix systems. You are not supposed to use it.

Upvotes: 3

Related Questions