classification
Title: Mention Py_SetProgramName in example for very high level embedding
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Matt.Jones, asvetlov, chris.jerdonek, docs@python, python-dev
Priority: normal Keywords: easy, patch

Created on 2012-10-31 10:50 by asvetlov, last changed 2012-10-31 14:05 by asvetlov. This issue is now closed.

Files
File name Uploaded Description Edit
issue16370.diff asvetlov, 2012-10-31 10:58
Messages (5)
msg174269 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-31 10:50
On Fri, Oct 26, 2012 at 12:02 AM, Tom Epperly <epperly2@llnl.gov> wrote:
Regarding this section, http://docs.python.org/extending/embedding.html#very-high-level-embedding, according to http://docs.python.org/c-api/init.html Py_SetProgramName() should be called before Py_Initialize() (see the comment for Py_SetProgramName()). This matters for the particular case of Mac OS X (see http://mail.python.org/pipermail/pythonmac-sig/2012-October/023746.html).

I recommend adding a Py_SetProgramName() to the example.

Regards,

Tom Epperly
msg174270 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-31 10:58
Patch for 2.7 applied, the same text should be for 3.2+

Chris, please check my wording as native English speaker.
msg174274 - (view) Author: Matt Jones (Matt.Jones) Date: 2012-10-31 13:36
Andrew, below is a revision of your comment with a few corrections made by a native english speaker.

********************
Function :c:func:`Py_SetProgramName` should be called before :c:func:`Py_Initialize` to inform the interpreter about paths to Python run-time libraries.  Next initialize the Python interpreter with :c:func:`Py_Initialize`, followed by the execution of a hard-coded Python script that prints the date and time.  Afterwards, the :c:func:`Py_Finalize` call shuts the interpreter down, followed by the end of the program.  In a real program, you may want to get the Python script from another source, perhaps a text-editor routine, a file, or a database.  Getting the Python code from a file can better be done by using the :c:func:`PyRun_SimpleFile` function, which saves you the trouble of allocating memory space and loading the file contents.
msg174277 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-10-31 14:04
New changeset 6e24eb832fb2 by Andrew Svetlov in branch '2.7':
Issue #16370: Mention Py_SetProgramName in example for very high level embedding.
http://hg.python.org/cpython/rev/6e24eb832fb2

New changeset 4c35f5ec6acf by Andrew Svetlov in branch '3.2':
Issue #16370: Mention Py_SetProgramName in example for very high level embedding.
http://hg.python.org/cpython/rev/4c35f5ec6acf

New changeset b6a5f54e0a34 by Andrew Svetlov in branch '3.3':
Merge issue #16370: Mention Py_SetProgramName in example for very high level embedding.
http://hg.python.org/cpython/rev/b6a5f54e0a34

New changeset 0c1b81465d9c by Andrew Svetlov in branch 'default':
Merge issue #16370: Mention Py_SetProgramName in example for very high level embedding.
http://hg.python.org/cpython/rev/0c1b81465d9c
msg174278 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-31 14:05
Thanks, Matt!
History
Date User Action Args
2012-10-31 14:05:39asvetlovsetstatus: open -> closed
title: Regarding embedding Python in Another Application -> Mention Py_SetProgramName in example for very high level embedding
type: enhancement
messages: + msg174278

resolution: fixed
stage: resolved
2012-10-31 14:04:35python-devsetnosy: + python-dev
messages: + msg174277
2012-10-31 13:36:24Matt.Jonessetnosy: + Matt.Jones
messages: + msg174274
2012-10-31 10:58:34asvetlovsetfiles: + issue16370.diff

nosy: + chris.jerdonek
messages: + msg174270

keywords: + patch
2012-10-31 10:50:51asvetlovcreate