mirror of
https://github.com/python/cpython.git
synced 2025-10-22 22:53:06 +00:00
Merge with 3.2.
This commit is contained in:
commit
c9d2fc390d
2 changed files with 4 additions and 3 deletions
|
@ -155,13 +155,13 @@ for data conversion between Python and C, and for error reporting. The
|
||||||
interesting part with respect to embedding Python starts with ::
|
interesting part with respect to embedding Python starts with ::
|
||||||
|
|
||||||
Py_Initialize();
|
Py_Initialize();
|
||||||
pName = PyString_FromString(argv[1]);
|
pName = PyUnicode_FromString(argv[1]);
|
||||||
/* Error checking of pName left out */
|
/* Error checking of pName left out */
|
||||||
pModule = PyImport_Import(pName);
|
pModule = PyImport_Import(pName);
|
||||||
|
|
||||||
After initializing the interpreter, the script is loaded using
|
After initializing the interpreter, the script is loaded using
|
||||||
:c:func:`PyImport_Import`. This routine needs a Python string as its argument,
|
:c:func:`PyImport_Import`. This routine needs a Python string as its argument,
|
||||||
which is constructed using the :c:func:`PyString_FromString` data conversion
|
which is constructed using the :c:func:`PyUnicode_FromString` data conversion
|
||||||
routine. ::
|
routine. ::
|
||||||
|
|
||||||
pFunc = PyObject_GetAttrString(pModule, argv[2]);
|
pFunc = PyObject_GetAttrString(pModule, argv[2]);
|
||||||
|
|
|
@ -79,6 +79,7 @@ To show the individual process IDs involved, here is an expanded example::
|
||||||
def info(title):
|
def info(title):
|
||||||
print(title)
|
print(title)
|
||||||
print('module name:', __name__)
|
print('module name:', __name__)
|
||||||
|
if hasattr(os, 'getppid'): # only available on Unix
|
||||||
print('parent process:', os.getppid())
|
print('parent process:', os.getppid())
|
||||||
print('process id:', os.getpid())
|
print('process id:', os.getpid())
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue