Skip to content

Commit 34b1627

Browse files
committed
Merge documentation update.
[SVN r63517]
1 parent 569b395 commit 34b1627

9 files changed

Lines changed: 611 additions & 640 deletions

File tree

doc/tutorial/doc/html/index.html

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<html>
22
<head>
3-
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
4-
<title>Chapter 1. python 2.0</title>
5-
<link rel="stylesheet" href="../../../../../../doc/html/boostbook.css" type="text/css">
6-
<meta name="generator" content="DocBook XSL Stylesheets V1.66.1">
7-
<link rel="start" href="index.html" title="Chapter 1. python 1.0">
8-
<link rel="next" href="python/hello.html" title=" Building Hello World">
3+
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4+
<title>Chapter&#160;1.&#160;python 2.0</title>
5+
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
6+
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
7+
<link rel="home" href="index.html" title="Chapter&#160;1.&#160;python 2.0">
8+
<link rel="next" href="python/hello.html" title="Building Hello World">
99
</head>
1010
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
1111
<table cellpadding="2" width="100%"><tr>
@@ -17,21 +17,21 @@
1717
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
1818
</tr></table>
1919
<hr>
20-
<div class="spirit-nav"><a accesskey="n" href="python/hello.html"><img src="../../../../../../doc/html/images/next.png" alt="Next"></a></div>
21-
<div class="chapter" lang="en">
20+
<div class="spirit-nav"><a accesskey="n" href="python/hello.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a></div>
21+
<div class="chapter">
2222
<div class="titlepage"><div>
2323
<div><h2 class="title">
24-
<a name="python"></a>Chapter 1. python 1.0</h2></div>
24+
<a name="python"></a>Chapter&#160;1.&#160;python 2.0</h2></div>
2525
<div><div class="author"><h3 class="author">
2626
<span class="firstname">Joel</span> <span class="surname">de Guzman</span>
2727
</h3></div></div>
2828
<div><div class="author"><h3 class="author">
2929
<span class="firstname">David</span> <span class="surname">Abrahams</span>
3030
</h3></div></div>
31-
<div><p class="copyright">Copyright © 2002-2005 Joel
31+
<div><p class="copyright">Copyright &#169; 2002-2005 Joel
3232
de Guzman, David Abrahams</p></div>
3333
<div><div class="legalnotice">
34-
<a name="id457106"></a><p>
34+
<a name="id759709"></a><p>
3535
Distributed under the Boost Software License, Version 1.0. (See accompanying
3636
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">
3737
http://www.boost.org/LICENSE_1_0.txt </a>)
@@ -79,7 +79,7 @@
7979
</dl></dd>
8080
</dl>
8181
</div>
82-
<div class="section" lang="en">
82+
<div class="section">
8383
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
8484
<a name="python.quickstart"></a>QuickStart</h2></div></div></div>
8585
<p>
@@ -93,10 +93,10 @@
9393
code takes on the look of a kind of declarative interface definition language
9494
(IDL).
9595
</p>
96-
<a name="quickstart.hello_world"></a><h2>
97-
<a name="id386707"></a>
96+
<a name="quickstart.hello_world"></a><h3>
97+
<a name="id759740"></a>
9898
Hello World
99-
</h2>
99+
</h3>
100100
<p>
101101
Following C/C++ tradition, let's start with the "hello, world". A
102102
C++ Function:
@@ -129,23 +129,17 @@
129129
</pre>
130130
<p>
131131
</p>
132-
<div class="blockquote"><blockquote class="blockquote">
133-
<p>
134-
</p>
135-
<p>
136-
<span class="emphasis"><em><span class="bold"><b>Next stop... Building your Hello World
137-
module from start to finish...</b></span></em></span>
138-
</p>
139-
<p>
140-
</p>
141-
</blockquote></div>
132+
<div class="blockquote"><blockquote class="blockquote"><p>
133+
<span class="emphasis"><em><span class="bold"><strong>Next stop... Building your Hello World module
134+
from start to finish...</strong></span></em></span>
135+
</p></blockquote></div>
142136
</div>
143137
</div>
144138
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
145-
<td align="left"><p><small>Last revised: November 22, 2008 at 03:24:11 GMT</small></p></td>
139+
<td align="left"><p><small>Last revised: July 01, 2010 at 21:56:58 GMT</small></p></td>
146140
<td align="right"><div class="copyright-footer"></div></td>
147141
</tr></table>
148142
<hr>
149-
<div class="spirit-nav"><a accesskey="n" href="python/hello.html"><img src="../../../../../../doc/html/images/next.png" alt="Next"></a></div>
143+
<div class="spirit-nav"><a accesskey="n" href="python/hello.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a></div>
150144
</body>
151145
</html>

doc/tutorial/doc/html/python/embedding.html

Lines changed: 59 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<html>
22
<head>
3-
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
3+
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
44
<title>Embedding</title>
5-
<link rel="stylesheet" href="../../../../../../../doc/html/boostbook.css" type="text/css">
6-
<meta name="generator" content="DocBook XSL Stylesheets V1.66.1">
7-
<link rel="start" href="../index.html" title="Chapter 1. python 1.0">
8-
<link rel="up" href="../index.html" title="Chapter 1. python 1.0">
9-
<link rel="prev" href="object.html" title=" Object Interface">
5+
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
6+
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
7+
<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;python 2.0">
8+
<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;python 2.0">
9+
<link rel="prev" href="object.html" title="Object Interface">
1010
<link rel="next" href="iterators.html" title="Iterators">
1111
</head>
1212
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
@@ -20,9 +20,9 @@
2020
</tr></table>
2121
<hr>
2222
<div class="spirit-nav">
23-
<a accesskey="p" href="object.html"><img src="../../../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="iterators.html"><img src="../../../../../../../doc/html/images/next.png" alt="Next"></a>
23+
<a accesskey="p" href="object.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="iterators.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
2424
</div>
25-
<div class="section" lang="en">
25+
<div class="section">
2626
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
2727
<a name="python.embedding"></a>Embedding</h2></div></div></div>
2828
<div class="toc"><dl><dt><span class="section"><a href="embedding.html#python.using_the_interpreter">Using the interpreter</a></span></dt></dl></div>
@@ -39,28 +39,28 @@
3939
a lot easier and, in a future version, it may become unnecessary to touch the
4040
Python/C API at all. So stay tuned... <span class="inlinemediaobject"><img src="../images/smiley.png" alt="smiley"></span>
4141
</p>
42-
<a name="embedding.building_embedded_programs"></a><h2>
43-
<a name="id472330"></a>
42+
<a name="embedding.building_embedded_programs"></a><h3>
43+
<a name="id773307"></a>
4444
Building embedded programs
45-
</h2>
45+
</h3>
4646
<p>
4747
To be able to embed python into your programs, you have to link to both Boost.Python's
4848
as well as Python's own runtime library.
4949
</p>
5050
<p>
5151
Boost.Python's library comes in two variants. Both are located in Boost's
52-
<tt class="literal">/libs/python/build/bin-stage</tt> subdirectory. On Windows, the
53-
variants are called <tt class="literal">boost_python.lib</tt> (for release builds)
54-
and <tt class="literal">boost_python_debug.lib</tt> (for debugging). If you can't
52+
<code class="literal">/libs/python/build/bin-stage</code> subdirectory. On Windows, the
53+
variants are called <code class="literal">boost_python.lib</code> (for release builds)
54+
and <code class="literal">boost_python_debug.lib</code> (for debugging). If you can't
5555
find the libraries, you probably haven't built Boost.Python yet. See <a href="../../../../building.html" target="_top">Building and Testing</a> on how to do this.
5656
</p>
5757
<p>
58-
Python's library can be found in the <tt class="literal">/libs</tt> subdirectory
58+
Python's library can be found in the <code class="literal">/libs</code> subdirectory
5959
of your Python directory. On Windows it is called pythonXY.lib where X.Y is
6060
your major Python version number.
6161
</p>
6262
<p>
63-
Additionally, Python's <tt class="literal">/include</tt> subdirectory has to be added
63+
Additionally, Python's <code class="literal">/include</code> subdirectory has to be added
6464
to your include path.
6565
</p>
6666
<p>
@@ -81,67 +81,61 @@
8181
&lt;library-path&gt;$(PYTHON_LIB_PATH)
8282
&lt;find-library&gt;$(PYTHON_EMBEDDED_LIBRARY) ;
8383
</pre>
84-
<a name="embedding.getting_started"></a><h2>
85-
<a name="id472435"></a>
84+
<a name="embedding.getting_started"></a><h3>
85+
<a name="id773391"></a>
8686
Getting started
87-
</h2>
87+
</h3>
8888
<p>
8989
Being able to build is nice, but there is nothing to build yet. Embedding the
9090
Python interpreter into one of your C++ programs requires these 4 steps:
9191
</p>
92-
<div class="orderedlist"><ol type="1">
93-
<li>
94-
#include <tt class="literal">&lt;boost/python.hpp&gt;</tt>
95-
</li>
96-
<li>
97-
Call <a href="http://www.python.org/doc/current/api/initialization.html#l2h-652" target="_top">Py_Initialize</a>()
98-
to start the interpreter and create the <tt class="literal"><span class="underline">_main</span>_</tt>
99-
module.
100-
</li>
101-
<li>
102-
Call other Python C API routines to use the interpreter.
103-
</li>
92+
<div class="orderedlist"><ol class="orderedlist" type="1">
93+
<li class="listitem">
94+
#include <code class="literal">&lt;boost/python.hpp&gt;</code>
95+
</li>
96+
<li class="listitem">
97+
Call <a href="http://www.python.org/doc/current/api/initialization.html#l2h-652" target="_top">Py_Initialize</a>()
98+
to start the interpreter and create the <code class="literal"><span class="underline">_main</span>_</code>
99+
module.
100+
</li>
101+
<li class="listitem">
102+
Call other Python C API routines to use the interpreter.
103+
</li>
104104
</ol></div>
105105
<div class="note"><table border="0" summary="Note">
106106
<tr>
107-
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/html/images/note.png"></td>
107+
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
108108
<th align="left">Note</th>
109109
</tr>
110-
<tr><td colspan="2" align="left" valign="top"><p>
111-
<span class="bold"><b>Note that at this time you must not call <a href="http://www.python.org/doc/current/api/initialization.html#l2h-656" target="_top">Py_Finalize</a>()
112-
to stop the interpreter. This may be fixed in a future version of boost.python.</b></span>
110+
<tr><td align="left" valign="top"><p>
111+
<span class="bold"><strong>Note that at this time you must not call <a href="http://www.python.org/doc/current/api/initialization.html#l2h-656" target="_top">Py_Finalize</a>()
112+
to stop the interpreter. This may be fixed in a future version of boost.python.</strong></span>
113113
</p></td></tr>
114114
</table></div>
115115
<p>
116116
(Of course, there can be other C++ code between all of these steps.)
117117
</p>
118-
<div class="blockquote"><blockquote class="blockquote">
119-
<p>
120-
</p>
121-
<p>
122-
<span class="emphasis"><em><span class="bold"><b>Now that we can embed the interpreter in
123-
our programs, lets see how to put it to use...</b></span></em></span>
124-
</p>
125-
<p>
126-
</p>
127-
</blockquote></div>
128-
<div class="section" lang="en">
118+
<div class="blockquote"><blockquote class="blockquote"><p>
119+
<span class="emphasis"><em><span class="bold"><strong>Now that we can embed the interpreter in
120+
our programs, lets see how to put it to use...</strong></span></em></span>
121+
</p></blockquote></div>
122+
<div class="section">
129123
<div class="titlepage"><div><div><h3 class="title">
130124
<a name="python.using_the_interpreter"></a>Using the interpreter</h3></div></div></div>
131125
<p>
132126
As you probably already know, objects in Python are reference-counted. Naturally,
133-
the <tt class="literal">PyObject</tt>s of the Python C API are also reference-counted.
127+
the <code class="literal">PyObject</code>s of the Python C API are also reference-counted.
134128
There is a difference however. While the reference-counting is fully automatic
135129
in Python, the Python C API requires you to do it <a href="http://www.python.org/doc/current/c-api/refcounting.html" target="_top">by
136130
hand</a>. This is messy and especially hard to get right in the presence
137131
of C++ exceptions. Fortunately Boost.Python provides the <a href="../../../../v2/handle.html" target="_top">handle</a>
138132
and <a href="../../../../v2/object.html" target="_top">object</a> class templates to
139133
automate the process.
140134
</p>
141-
<a name="using_the_interpreter.running_python_code"></a><h2>
142-
<a name="id472601"></a>
135+
<a name="using_the_interpreter.running_python_code"></a><h3>
136+
<a name="id773549"></a>
143137
Running Python code
144-
</h2>
138+
</h3>
145139
<p>
146140
Boost.python provides three related functions to run Python code from C++.
147141
</p>
@@ -155,10 +149,10 @@
155149
and exec_file executes the code contained in the given file.
156150
</p>
157151
<p>
158-
The <tt class="literal">globals</tt> and <tt class="literal">locals</tt> parameters are
152+
The <code class="literal">globals</code> and <code class="literal">locals</code> parameters are
159153
Python dictionaries containing the globals and locals of the context in which
160154
to run the code. For most intents and purposes you can use the namespace
161-
dictionary of the <tt class="literal"><span class="underline">_main</span>_</tt>
155+
dictionary of the <code class="literal"><span class="underline">_main</span>_</code>
162156
module for both parameters.
163157
</p>
164158
<p>
@@ -171,7 +165,7 @@
171165
first), and returns it.
172166
</p>
173167
<p>
174-
Let's import the <tt class="literal"><span class="underline">_main</span>_</tt>
168+
Let's import the <code class="literal"><span class="underline">_main</span>_</code>
175169
module and run some Python code in its namespace:
176170
</p>
177171
<pre class="programlisting"><span class="identifier">object</span> <span class="identifier">main_module</span> <span class="special">=</span> <span class="identifier">import</span><span class="special">(</span><span class="string">"__main__"</span><span class="special">);</span>
@@ -186,15 +180,15 @@
186180
This should create a file called 'hello.txt' in the current directory containing
187181
a phrase that is well-known in programming circles.
188182
</p>
189-
<a name="using_the_interpreter.manipulating_python_objects"></a><h2>
190-
<a name="id473185"></a>
183+
<a name="using_the_interpreter.manipulating_python_objects"></a><h3>
184+
<a name="id774064"></a>
191185
Manipulating Python objects
192-
</h2>
186+
</h3>
193187
<p>
194188
Often we'd like to have a class to manipulate Python objects. But we have
195189
already seen such a class above, and in the <a href="object.html" target="_top">previous
196-
section</a>: the aptly named <tt class="literal">object</tt> class and its
197-
derivatives. We've already seen that they can be constructed from a <tt class="literal">handle</tt>.
190+
section</a>: the aptly named <code class="literal">object</code> class and its
191+
derivatives. We've already seen that they can be constructed from a <code class="literal">handle</code>.
198192
The following examples should further illustrate this fact:
199193
</p>
200194
<pre class="programlisting"><span class="identifier">object</span> <span class="identifier">main_module</span> <span class="special">=</span> <span class="identifier">import</span><span class="special">(</span><span class="string">"__main__"</span><span class="special">);</span>
@@ -203,18 +197,18 @@
203197
<span class="keyword">int</span> <span class="identifier">five_squared</span> <span class="special">=</span> <span class="identifier">extract</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;(</span><span class="identifier">main_namespace</span><span class="special">[</span><span class="string">"result"</span><span class="special">]);</span>
204198
</pre>
205199
<p>
206-
Here we create a dictionary object for the <tt class="literal"><span class="underline">_main</span>_</tt>
200+
Here we create a dictionary object for the <code class="literal"><span class="underline">_main</span>_</code>
207201
module's namespace. Then we assign 5 squared to the result variable and read
208202
this variable from the dictionary. Another way to achieve the same result
209203
is to use eval instead, which returns the result directly:
210204
</p>
211205
<pre class="programlisting"><span class="identifier">object</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">eval</span><span class="special">(</span><span class="string">"5 ** 2"</span><span class="special">);</span>
212206
<span class="keyword">int</span> <span class="identifier">five_squared</span> <span class="special">=</span> <span class="identifier">extract</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;(</span><span class="identifier">result</span><span class="special">);</span>
213207
</pre>
214-
<a name="using_the_interpreter.exception_handling"></a><h2>
215-
<a name="id473554"></a>
208+
<a name="using_the_interpreter.exception_handling"></a><h3>
209+
<a name="id774390"></a>
216210
Exception handling
217-
</h2>
211+
</h3>
218212
<p>
219213
If an exception occurs in the evaluation of the python expression, <a href="../../../../v2/errors.html#error_already_set-spec" target="_top">error_already_set</a>
220214
is thrown:
@@ -231,7 +225,7 @@
231225
</span><span class="special">}</span>
232226
</pre>
233227
<p>
234-
The <tt class="literal">error_already_set</tt> exception class doesn't carry any
228+
The <code class="literal">error_already_set</code> exception class doesn't carry any
235229
information in itself. To find out more about the Python exception that occurred,
236230
you need to use the <a href="http://www.python.org/doc/api/exceptionHandling.html" target="_top">exception
237231
handling functions</a> of the Python C API in your catch-statement. This
@@ -261,7 +255,7 @@
261255
</div>
262256
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
263257
<td align="left"></td>
264-
<td align="right"><div class="copyright-footer">Copyright © 2002-2005 Joel
258+
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005 Joel
265259
de Guzman, David Abrahams<p>
266260
Distributed under the Boost Software License, Version 1.0. (See accompanying
267261
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">
@@ -271,7 +265,7 @@
271265
</tr></table>
272266
<hr>
273267
<div class="spirit-nav">
274-
<a accesskey="p" href="object.html"><img src="../../../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="iterators.html"><img src="../../../../../../../doc/html/images/next.png" alt="Next"></a>
268+
<a accesskey="p" href="object.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="iterators.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
275269
</div>
276270
</body>
277271
</html>

0 commit comments

Comments
 (0)