Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e160b376
Commit
e160b376
authored
May 07, 2001
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added documentation for PyIter_Check() and PyIter_Next().
Wrapped a long line.
parent
227c26ce
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
1 deletion
+39
-1
Doc/api/api.tex
Doc/api/api.tex
+39
-1
No files found.
Doc/api/api.tex
View file @
e160b376
...
@@ -2082,13 +2082,51 @@ Return element of \var{o} corresponding to the object \var{key} or
...
@@ -2082,13 +2082,51 @@ Return element of \var{o} corresponding to the object \var{key} or
\samp
{
\var
{
o
}
[
\var
{
key
}
]
}
.
\samp
{
\var
{
o
}
[
\var
{
key
}
]
}
.
\end{cfuncdesc}
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyMapping
_
SetItemString
}{
PyObject *o, char *key, PyObject *v
}
\begin{cfuncdesc}
{
int
}{
PyMapping
_
SetItemString
}{
PyObject *o, char *key,
PyObject *v
}
Map the object
\var
{
key
}
to the value
\var
{
v
}
in object
\var
{
o
}
.
Map the object
\var
{
key
}
to the value
\var
{
v
}
in object
\var
{
o
}
.
Returns
\code
{
-1
}
on failure. This is the equivalent of the Python
Returns
\code
{
-1
}
on failure. This is the equivalent of the Python
statement
\samp
{
\var
{
o
}
[
\var
{
key
}
] =
\var
{
v
}}
.
statement
\samp
{
\var
{
o
}
[
\var
{
key
}
] =
\var
{
v
}}
.
\end{cfuncdesc}
\end{cfuncdesc}
\section
{
Iterator Protocol
\label
{
iterator
}}
There are only a couple of functions specifically for working with
iterators.
\begin{cfuncdesc}
{
int
}{
PyIter
_
Check
}{
PyObject *o
}
Return true if the object
\var
{
o
}
supports the iterator protocol.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyIter
_
Next
}{
PyObject *o
}
Return the next value from the iteration
\var
{
o
}
. If the object is
an iterator, this retrieves the next value from the iteration, and
returns
\NULL
{}
with no exception set if there are no remaining
items. If the object is not an iterator,
\exception
{
TypeError
}
is
raised, or if there is an error in retrieving the item, returns
\NULL
{}
and passes along the exception.
\end{cfuncdesc}
To write a loop which iterates over an iterator, the C code should
look something like this:
\begin{verbatim}
PyObject *iterator = ...;
PyObject *item;
while (item = PyIter
_
Next(iter))
{
/* do something with item */
}
if (PyErr
_
Occurred())
{
/* propogate error */
}
else
{
/* continue doing useful work */
}
\end{verbatim}
\chapter
{
Concrete Objects Layer
\label
{
concrete
}}
\chapter
{
Concrete Objects Layer
\label
{
concrete
}}
The functions in this chapter are specific to certain Python object
The functions in this chapter are specific to certain Python object
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment