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
8fe533e6
Commit
8fe533e6
authored
Mar 27, 1998
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the new {methoddesc} and {memberdesc} environments as appropriate.
parent
ec56109a
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
402 additions
and
414 deletions
+402
-414
Doc/lib/libformatter.tex
Doc/lib/libformatter.tex
+61
-64
Doc/lib/libhtmllib.tex
Doc/lib/libhtmllib.tex
+14
-17
Doc/lib/libpprint.tex
Doc/lib/libpprint.tex
+9
-10
Doc/lib/libprofile.tex
Doc/lib/libprofile.tex
+22
-22
Doc/lib/libqueue.tex
Doc/lib/libqueue.tex
+12
-14
Doc/lib/libsgmllib.tex
Doc/lib/libsgmllib.tex
+38
-39
Doc/lib/libstrio.tex
Doc/lib/libstrio.tex
+13
-7
Doc/lib/libtypes.tex
Doc/lib/libtypes.tex
+32
-34
Doc/libformatter.tex
Doc/libformatter.tex
+61
-64
Doc/libhtmllib.tex
Doc/libhtmllib.tex
+14
-17
Doc/libpprint.tex
Doc/libpprint.tex
+9
-10
Doc/libprofile.tex
Doc/libprofile.tex
+22
-22
Doc/libqueue.tex
Doc/libqueue.tex
+12
-14
Doc/libsgmllib.tex
Doc/libsgmllib.tex
+38
-39
Doc/libstrio.tex
Doc/libstrio.tex
+13
-7
Doc/libtypes.tex
Doc/libtypes.tex
+32
-34
No files found.
Doc/lib/libformatter.tex
View file @
8fe533e6
This diff is collapsed.
Click to expand it.
Doc/lib/libhtmllib.tex
View file @
8fe533e6
...
...
@@ -70,53 +70,50 @@ handlers for all HTML 2.0 and many HTML 3.0 and 3.2 elements.
In addition to tag methods, the
\class
{
HTMLParser
}
class provides some
additional methods and instance variables for use within tag methods.
\setindexsubitem
{
(HTMLParser attribute)
}
\begin{datadesc}
{
formatter
}
\begin{memberdesc}
{
formatter
}
This is the formatter instance associated with the parser.
\end{
data
desc}
\end{
member
desc}
\begin{
data
desc}
{
nofill
}
\begin{
member
desc}
{
nofill
}
Boolean flag which should be true when whitespace should not be
collapsed, or false when it should be. In general, this should only
be true when character data is to be treated as ``preformatted'' text,
as within a
\code
{
<PRE>
}
element. The default value is false. This
affects the operation of
\method
{
handle
_
data()
}
and
\method
{
save
_
end()
}
.
\end{
data
desc}
\end{
member
desc}
\setindexsubitem
{
(HTMLParser method)
}
\begin{
func
desc}
{
anchor
_
bgn
}{
href, name, type
}
\begin{
method
desc}
{
anchor
_
bgn
}{
href, name, type
}
This method is called at the start of an anchor region. The arguments
correspond to the attributes of the
\code
{
<A>
}
tag with the same
names. The default implementation maintains a list of hyperlinks
(defined by the
\code
{
href
}
attribute) within the document. The list
of hyperlinks is available as the data attribute
\code
{
anchorlist
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
anchor
_
end
}{}
\begin{
method
desc}
{
anchor
_
end
}{}
This method is called at the end of an anchor region. The default
implementation adds a textual footnote marker using an index into the
list of hyperlinks created by
\method
{
anchor
_
bgn()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
handle
_
image
}{
source, alt
\optional
{
, ismap
\optional
{
, align
\optional
{
, width
\optional
{
, height
}}}}}
\begin{
method
desc}
{
handle
_
image
}{
source, alt
\optional
{
, ismap
\optional
{
, align
\optional
{
, width
\optional
{
, height
}}}}}
This method is called to handle images. The default implementation
simply passes the
\var
{
alt
}
value to the
\method
{
handle
_
data()
}
method.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
save
_
bgn
}{}
\begin{
method
desc}
{
save
_
bgn
}{}
Begins saving character data in a buffer instead of sending it to the
formatter object. Retrieve the stored data via
\method
{
save
_
end()
}
.
Use of the
\method
{
save
_
bgn()
}
/
\method
{
save
_
end()
}
pair may not be
nested.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
save
_
end
}{}
\begin{
method
desc}
{
save
_
end
}{}
Ends buffering character data and returns all data saved since the
preceeding call to
\method
{
save
_
bgn()
}
. If the
\code
{
nofill
}
flag is
false, whitespace is collapsed to single spaces. A call to this
method without a preceeding call to
\method
{
save
_
bgn()
}
will raise a
\exception
{
TypeError
}
exception.
\end{
func
desc}
\end{
method
desc}
Doc/lib/libpprint.tex
View file @
8fe533e6
...
...
@@ -142,32 +142,31 @@ l/lib/python1.4/test', '/usr/local/lib/python1.4/sunos5', '/usr/local/lib/python
\class
{
PrettyPrinter
}
instances have the following methods:
\setindexsubitem
{
(PrettyPrinter method)
}
\begin{
func
desc}
{
pformat
}{
object
}
\begin{
method
desc}
{
pformat
}{
object
}
Return the formatted representation of
\var
{
object
}
. This takes into
a
ccount the options passed to the
\class
{
PrettyPrinter
}
constructor.
\end{
func
desc}
A
ccount the options passed to the
\class
{
PrettyPrinter
}
constructor.
\end{
method
desc}
\begin{
func
desc}
{
pprint
}{
object
}
\begin{
method
desc}
{
pprint
}{
object
}
Print the formatted representation of
\var
{
object
}
on the configured
stream, followed by a newline.
\end{
func
desc}
\end{
method
desc}
The following methods provide the implementations for the
corresponding functions of the same names. Using these methods on an
instance is slightly more efficient since new
\class
{
PrettyPrinter
}
objects don't need to be created.
\begin{
func
desc}
{
isreadable
}{
object
}
\begin{
method
desc}
{
isreadable
}{
object
}
Determine if the formatted representation of the object is
``readable,'' or can be used to reconstruct the value using
\function
{
eval()
}
\bifuncindex
{
eval
}
. Note that this returns false for
recursive objects. If the
\var
{
depth
}
parameter of the
\class
{
PrettyPrinter
}
is set and the object is deeper than allowed,
this returns false.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
isrecursive
}{
object
}
\begin{
method
desc}
{
isrecursive
}{
object
}
Determine if the object requires a recursive representation.
\end{
func
desc}
\end{
method
desc}
Doc/lib/libprofile.tex
View file @
8fe533e6
\chapter
{
The Python Profiler
}
\label
{
profile
}
\stmodindex
{
profile
}
\stmodindex
{
pstats
}
Copyright
\copyright
{}
1994, by InfoSeek Corporation, all rights reserved.
...
...
@@ -256,8 +254,9 @@ of algorithms to be directly compared to iterative implementations.
\section
{
Reference Manual
}
\stmodindex
{
profile
}
\label
{
module-profile
}
\setindexsubitem
{
(in module profile)
}
The primary entry point for the profiler is the global function
\function
{
profile.run()
}
. It is typically used to create any profile
...
...
@@ -269,7 +268,7 @@ Profiler Extensions, which includes discussion of how to derive
``better'' profilers from the classes presented, or reading the source
code for these modules.
\begin{funcdesc}
{
profile.
run
}{
string
\optional
{
, filename
\optional
{
, ...
}}}
\begin{funcdesc}
{
run
}{
string
\optional
{
, filename
\optional
{
, ...
}}}
This function takes a single argument that has can be passed to the
\keyword
{
exec
}
statement, and an optional file name. In all cases this
...
...
@@ -336,7 +335,8 @@ printed.
Analysis of the profiler data is done using this class from the
\module
{
pstats
}
module:
\setindexsubitem
{
(in module pstats)
}
% now switch modules....
\stmodindex
{
pstats
}
\begin{classdesc}
{
Stats
}{
filename
\optional
{
, ...
}}
This class constructor creates an instance of a ``statistics object''
...
...
@@ -361,7 +361,7 @@ need to be combined with data in an existing \class{Stats} object, the
\setindexsubitem
{
(Stats method)
}
\begin{
func
desc}
{
strip
_
dirs
}{}
\begin{
method
desc}
{
strip
_
dirs
}{}
This method for the
\class
{
Stats
}
class removes all leading path
information from file names. It is very useful in reducing the size
of the printout to fit within (close to) 80 columns. This method
...
...
@@ -372,19 +372,19 @@ initialization and loading. If \method{strip_dirs()} causes two
function names to be indistinguishable (i.e., they are on the same
line of the same filename, and have the same function name), then the
statistics for these two entries are accumulated into a single entry.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
add
}{
filename
\optional
{
, ...
}}
\begin{
method
desc}
{
add
}{
filename
\optional
{
, ...
}}
This method of the
\class
{
Stats
}
class accumulates additional
profiling information into the current profiling object. Its
arguments should refer to filenames created by the corresponding
version of
\function
{
profile.run()
}
. Statistics for identically named
(re: file, line, name) functions are automatically accumulated into
single function statistics.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
sort
_
stats
}{
key
\optional
{
, ...
}}
\begin{
method
desc}
{
sort
_
stats
}{
key
\optional
{
, ...
}}
This method modifies the
\class
{
Stats
}
object by sorting it according
to the supplied criteria. The argument is typically a string
identifying the basis of a sort (example:
\code
{
"time"
}
or
...
...
@@ -430,18 +430,18 @@ interpreted as \code{"stdname"}, \code{"calls"}, \code{"time"}, and
\code
{
"cumulative"
}
respectively. If this old style format (numeric)
is used, only one sort key (the numeric key) will be used, and
additional arguments will be silently ignored.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
reverse
_
order
}{}
\begin{
method
desc}
{
reverse
_
order
}{}
This method for the
\class
{
Stats
}
class reverses the ordering of the basic
list within the object. This method is provided primarily for
compatibility with the old profiler. Its utility is questionable
now that ascending vs descending order is properly selected based on
the sort key of choice.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
print
_
stats
}{
restriction
\optional
{
, ...
}}
\begin{
method
desc}
{
print
_
stats
}{
restriction
\optional
{
, ...
}}
This method for the
\class
{
Stats
}
class prints out a report as described
in the
\function
{
profile.run()
}
definition.
...
...
@@ -473,10 +473,10 @@ print_stats("foo:", .1)
would limit the list to all functions having file names
\samp
{
.*foo:
}
,
and then proceed to only print the first 10
\%
of them.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
print
_
callers
}{
restrictions
\optional
{
, ...
}}
\begin{
method
desc}
{
print
_
callers
}{
restrictions
\optional
{
, ...
}}
This method for the
\class
{
Stats
}
class prints a list of all functions
that called each function in the profiled database. The ordering is
identical to that provided by
\method
{
print
_
stats()
}
, and the definition
...
...
@@ -484,16 +484,16 @@ of the restricting argument is also identical. For convenience, a
number is shown in parentheses after each caller to show how many
times this specific call was made. A second non-parenthesized number
is the cumulative time spent in the function at the right.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
print
_
callees
}{
restrictions
\optional
{
, ...
}}
\begin{
method
desc}
{
print
_
callees
}{
restrictions
\optional
{
, ...
}}
This method for the
\class
{
Stats
}
class prints a list of all function
that were called by the indicated function. Aside from this reversal
of direction of calls (re: called vs was called by), the arguments and
ordering are identical to the
\method
{
print
_
callers()
}
method.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
ignore
}{}
\begin{
method
desc}
{
ignore
}{}
This method of the
\class
{
Stats
}
class is used to dispose of the value
returned by earlier methods. All standard methods in this class
return the instance that is being processed, so that the commands can
...
...
@@ -503,7 +503,7 @@ be strung together. For example:
pstats.Stats('foofile').strip
_
dirs().sort
_
stats('cum')
\
.print
_
stats().ignore()
\end{verbatim}
%
would perform all the indicated functions, but it would not return
the final reference to the
\class
{
Stats
}
instance.
%
\footnote
{
...
...
@@ -511,7 +511,7 @@ This was once necessary, when Python would print any unused expression
result that was not
\code
{
None
}
. The method is still defined for
backward compatibility.
}
\end{
func
desc}
\end{
method
desc}
\section
{
Limitations
}
...
...
Doc/lib/libqueue.tex
View file @
8fe533e6
...
...
@@ -37,34 +37,32 @@ other queue organizations (e.g. stack) but the inheritable interface
is not described here. See the source code for details. The public
methods are:
\setindexsubitem
{
(Queue method)
}
\begin{funcdesc}
{
qsize
}{}
\begin{methoddesc}
{
qsize
}{}
Returns the approximate size of the queue. Because of multithreading
semantics, this number is not reliable.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
empty
}{}
\begin{
method
desc}
{
empty
}{}
Returns
\code
{
1
}
if the queue is empty,
\code
{
0
}
otherwise. Because
of multithreading semantics, this is not reliable.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
full
}{}
\begin{
method
desc}
{
full
}{}
Returns
\code
{
1
}
if the queue is full,
\code
{
0
}
otherwise. Because of
multithreading semantics, this is not reliable.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
put
}{
item
}
\begin{
method
desc}
{
put
}{
item
}
Puts
\var
{
item
}
into the queue.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
get
}{}
\begin{
method
desc}
{
get
}{}
Gets and returns an item from the queue, blocking if necessary until
one is available.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
get
_
nowait
}{}
\begin{
method
desc}
{
get
_
nowait
}{}
Gets and returns an item from the queue if one is immediately
available. Raises an
\exception
{
Empty
}
exception if the queue is
empty or if the queue's emptiness cannot be determined.
\end{
func
desc}
\end{
method
desc}
Doc/lib/libsgmllib.tex
View file @
8fe533e6
...
...
@@ -38,37 +38,36 @@ spaces, tabs, and newlines are allowed between the trailing
\class
{
SGMLParser
}
instances have the following interface methods:
\setindexsubitem
{
(SGMLParser method)
}
\begin{
func
desc}
{
reset
}{}
\begin{
method
desc}
{
reset
}{}
Reset the instance. Loses all unprocessed data. This is called
implicitly at instantiation time.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
setnomoretags
}{}
\begin{
method
desc}
{
setnomoretags
}{}
Stop processing tags. Treat all following input as literal input
(CDATA). (This is only provided so the HTML tag
\code
{
<PLAINTEXT>
}
can be implemented.)
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
setliteral
}{}
\begin{
method
desc}
{
setliteral
}{}
Enter literal mode (CDATA mode).
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
feed
}{
data
}
\begin{
method
desc}
{
feed
}{
data
}
Feed some text to the parser. It is processed insofar as it consists
of complete elements; incomplete data is buffered until more data is
fed or
\method
{
close()
}
is called.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
close
}{}
\begin{
method
desc}
{
close
}{}
Force processing of all buffered data as if it were followed by an
end-of-file mark. This method may be redefined by a derived class to
define additional processing at the end of the input, but the
redefined version should always call
\method
{
close()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
handle
_
starttag
}{
tag, method, attributes
}
\begin{
method
desc}
{
handle
_
starttag
}{
tag, method, attributes
}
This method is called to handle start tags for which either a
\code
{
start
_
\var
{
tag
}
()
}
or
\code
{
do
_
\var
{
tag
}
()
}
method has been
defined. The
\var
{
tag
}
argument is the name of the tag converted to
...
...
@@ -82,9 +81,9 @@ instance, for the tag \code{<A HREF="http://www.cwi.nl/">}, this
method would be called as
\samp
{
unknown
_
starttag('a', [('href',
'http://www.cwi.nl/')])
}
. The base implementation simply calls
\var
{
method
}
with
\var
{
attributes
}
as the only argument.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
handle
_
endtag
}{
tag, method
}
\begin{
method
desc}
{
handle
_
endtag
}{
tag, method
}
This method is called to handle endtags for which an
\code
{
end
_
\var
{
tag
}
()
}
method has been defined. The
\var
{
tag
}
argument is the name of the tag converted to lower case, and the
...
...
@@ -93,15 +92,15 @@ support semantic interpretation of the end tag. If no
\code
{
end
_
\var
{
tag
}
()
}
method is defined for the closing element,
this handler is not called. The base implementation simply calls
\var
{
method
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
handle
_
data
}{
data
}
\begin{
method
desc}
{
handle
_
data
}{
data
}
This method is called to process arbitrary data. It is intended to be
overridden by a derived class; the base class implementation does
nothing.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
handle
_
charref
}{
ref
}
\begin{
method
desc}
{
handle
_
charref
}{
ref
}
This method is called to process a character reference of the form
\samp
{
\&\#\var
{
ref
}
;
}
. In the base implementation,
\var
{
ref
}
must
be a decimal number in the
...
...
@@ -111,9 +110,9 @@ method \method{handle_data()} with the character as argument. If
\code
{
unknown
_
charref(
\var
{
ref
}
)
}
is called to handle the error. A
subclass must override this method to provide support for named
character entities.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
handle
_
entityref
}{
ref
}
\begin{
method
desc}
{
handle
_
entityref
}{
ref
}
This method is called to process a general entity reference of the
form
\samp
{
\&\var
{
ref
}
;
}
where
\var
{
ref
}
is an general entity
reference. It looks for
\var
{
ref
}
in the instance (or class)
...
...
@@ -124,46 +123,46 @@ with the translation; otherwise, it calls the method
\code
{
unknown
_
entityref(
\var
{
ref
}
)
}
. The default
\member
{
entitydefs
}
defines translations for
\code
{
\&
amp;
}
,
\code
{
\&
apos
}
,
\code
{
\&
gt;
}
,
\code
{
\&
lt;
}
, and
\code
{
\&
quot;
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
handle
_
comment
}{
comment
}
\begin{
method
desc}
{
handle
_
comment
}{
comment
}
This method is called when a comment is encountered. The
\var
{
comment
}
argument is a string containing the text between the
\samp
{
<!--
}
and
\samp
{
-->
}
delimiters, but not the delimiters
themselves. For example, the comment
\samp
{
<!--text-->
}
will
cause this method to be called with the argument
\code
{
'text'
}
. The
default method does nothing.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
report
_
unbalanced
}{
tag
}
\begin{
method
desc}
{
report
_
unbalanced
}{
tag
}
This method is called when an end tag is found which does not
correspond to any open element.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
unknown
_
starttag
}{
tag, attributes
}
\begin{
method
desc}
{
unknown
_
starttag
}{
tag, attributes
}
This method is called to process an unknown start tag. It is intended
to be overridden by a derived class; the base class implementation
does nothing.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
unknown
_
endtag
}{
tag
}
\begin{
method
desc}
{
unknown
_
endtag
}{
tag
}
This method is called to process an unknown end tag. It is intended
to be overridden by a derived class; the base class implementation
does nothing.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
unknown
_
charref
}{
ref
}
\begin{
method
desc}
{
unknown
_
charref
}{
ref
}
This method is called to process unresolvable numeric character
references. Refer to
\method
{
handle
_
charref()
}
to determine what is
handled by default. It is intended to be overridden by a derived
class; the base class implementation does nothing.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
unknown
_
entityref
}{
ref
}
\begin{
method
desc}
{
unknown
_
entityref
}{
ref
}
This method is called to process an unknown entity reference. It is
intended to be overridden by a derived class; the base class
implementation does nothing.
\end{
func
desc}
\end{
method
desc}
Apart from overriding or extending the methods listed above, derived
classes may also define methods of the following form to define
...
...
@@ -171,22 +170,22 @@ processing of specific tags. Tag names in the input stream are case
independent; the
\var
{
tag
}
occurring in method names must be in lower
case:
\begin{
func
descni}
{
start
_
\var
{
tag
}}{
attributes
}
\begin{
method
descni}
{
start
_
\var
{
tag
}}{
attributes
}
This method is called to process an opening tag
\var
{
tag
}
. It has
preference over
\code
{
do
_
\var
{
tag
}
()
}
. The
\var
{
attributes
}
argument has the same meaning as described for
\method
{
handle
_
starttag()
}
above.
\end{
func
descni}
\end{
method
descni}
\begin{
func
descni}
{
do
_
\var
{
tag
}}{
attributes
}
\begin{
method
descni}
{
do
_
\var
{
tag
}}{
attributes
}
This method is called to process an opening tag
\var
{
tag
}
that does
not come with a matching closing tag. The
\var
{
attributes
}
argument
has the same meaning as described for
\method
{
handle
_
starttag()
}
above.
\end{
func
descni}
\end{
method
descni}
\begin{
func
descni}
{
end
_
\var
{
tag
}}{}
\begin{
method
descni}
{
end
_
\var
{
tag
}}{}
This method is called to process a closing tag
\var
{
tag
}
.
\end{
func
descni}
\end{
method
descni}
Note that the parser maintains a stack of open elements for which no
end tag has been found yet. Only tags processed by
...
...
Doc/lib/libstrio.tex
View file @
8fe533e6
...
...
@@ -3,15 +3,21 @@
\stmodindex
{
StringIO
}
This module implements a file-like class,
\c
ode
{
StringIO
}
,
This module implements a file-like class,
\c
lass
{
StringIO
}
,
that reads and writes a string buffer (also known as
\emph
{
memory
files
}
). See the description on file objects for operations.
When a
\code
{
StringIO
}
object is created, it can be initialized
\begin{classdesc}
{
StringIO
}{
\optional
{
buffer
}}
When a
\class
{
StringIO
}
object is created, it can be initialized
to an existing string by passing the string to the constructor.
If no string is given, the
\code
{
StringIO
}
will start empty.
If no string is given, the
\class
{
StringIO
}
will start empty.
\end{classdesc}
The method
\code
{
getvalue()
}
can be called to retrieve the entire
contents of the ``file'' at any time before the
\code
{
StringIO
}
object's
\code
{
close()
}
method is called. Calling
\code
{
close()
}
will
free the memory buffer.
\begin{methoddesc}
{
getvalue
}{}
Retrieve the entire contents of the ``file'' at any time before the
\class
{
StringIO
}
object's
\method
{
close()
}
method is called.
\end{methoddesc}
\begin{methoddesc}
{
close
}{}
Free the memory buffer.
\end{methoddesc}
Doc/lib/libtypes.tex
View file @
8fe533e6
...
...
@@ -707,30 +707,28 @@ device or writing a file opened for reading.
Files have the following methods:
\setindexsubitem
{
(file method)
}
\begin{funcdesc}
{
close
}{}
\begin{methoddesc}
[file]
{
close
}{}
Close the file. A closed file cannot be read or written anymore.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
flush
}{}
\begin{
methoddesc}
[file]
{
flush
}{}
Flush the internal buffer, like
\code
{
stdio
}
's
\code
{
fflush()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
isatty
}{}
\begin{
methoddesc}
[file]
{
isatty
}{}
Return
\code
{
1
}
if the file is connected to a tty(-like) device, else
\code
{
0
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
fileno
}{}
\begin{
methoddesc}
[file]
{
fileno
}{}
Return the integer ``file descriptor'' that is used by the underlying
implementation to request I/O operations from the operating system.
This can be useful for other, lower level interfaces that use file
descriptors, e.g. module
\code
{
fcntl
}
or
\code
{
os.read()
}
and friends.
\refbimodindex
{
fcntl
}
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
read
}{
\optional
{
size
}}
\begin{
methoddesc}
[file]
{
read
}{
\optional
{
size
}}
Read at most
\var
{
size
}
bytes from the file (less if the read hits
\EOF
{}
or no more data is immediately available on a pipe, tty or
similar device). If the
\var
{
size
}
argument is negative or omitted,
...
...
@@ -738,9 +736,9 @@ descriptors, e.g. module \code{fcntl} or \code{os.read()} and friends.
object. An empty string is returned when
\EOF
{}
is encountered
immediately. (For certain files, like ttys, it makes sense to
continue reading after an
\EOF
{}
is hit.)
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
readline
}{
\optional
{
size
}}
\begin{
methoddesc}
[file]
{
readline
}{
\optional
{
size
}}
Read one entire line from the file. A trailing newline character is
kept in the string
%
\footnote
{
The advantage of leaving the newline on is that an empty string
...
...
@@ -757,71 +755,71 @@ descriptors, e.g. module \code{fcntl} or \code{os.read()} and friends.
immediately. Note: unlike
\code
{
stdio
}
's
\code
{
fgets()
}
, the returned
string contains null characters (
\code
{
'
\e
0'
}
) if they occurred in the
input.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
readlines
}{
\optional
{
sizehint
}}
\begin{
methoddesc}
[file]
{
readlines
}{
\optional
{
sizehint
}}
Read until
\EOF
{}
using
\code
{
readline()
}
and return a list containing
the lines thus read. If the optional
\var
{
sizehint
}
argument is
present, instead of reading up to
\EOF
{}
, whole lines totalling
approximately
\var
{
sizehint
}
bytes (possibly after rounding up to an
internal buffer size) are read.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
seek
}{
offset, whence
}
\begin{
methoddesc}
[file]
{
seek
}{
offset, whence
}
Set the file's current position, like
\code
{
stdio
}
's
\code
{
fseek()
}
.
The
\var
{
whence
}
argument is optional and defaults to
\code
{
0
}
(absolute file positioning); other values are
\code
{
1
}
(seek
relative to the current position) and
\code
{
2
}
(seek relative to the
file's end). There is no return value.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
tell
}{}
\begin{
methoddesc}
[file]
{
tell
}{}
Return the file's current position, like
\code
{
stdio
}
's
\code
{
ftell()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
truncate
}{
\optional
{
size
}}
\begin{
methoddesc}
[file]
{
truncate
}{
\optional
{
size
}}
Truncate the file's size. If the optional size argument present, the
file is truncated to (at most) that size. The size defaults to the
current position. Availability of this function depends on the
operating system version (e.g., not all
\UNIX
{}
versions support this
operation).
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
write
}{
str
}
\begin{
methoddesc}
[file]
{
write
}{
str
}
Write a string to the file. There is no return value. Note: due to
buffering, the string may not actually show up in the file until
the
\code
{
flush()
}
or
\code
{
close()
}
method is called.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
writelines
}{
list
}
\begin{
methoddesc}
[file]
{
writelines
}{
list
}
Write a list of strings to the file. There is no return value.
(The name is intended to match
\code
{
readlines
}
;
\code
{
writelines
}
does not add line separators.)
\end{
func
desc}
\end{
method
desc}
File objects also offer the following attributes:
\setindexsubitem
{
(file attribute)
}
\begin{
datadesc}
{
closed
}
\begin{
memberdesc}
[file]
{
closed
}
Boolean indicating the current state of the file object. This is a
read-only attribute; the
\method
{
close()
}
method changes the value.
\end{
data
desc}
\end{
member
desc}
\begin{
datadesc}
{
mode
}
\begin{
memberdesc}
[file]
{
mode
}
The I/O mode for the file. If the file was created using the
\function
{
open()
}
built-in function, this will be the value of the
\var
{
mode
}
parameter. This is a read-only attribute.
\end{
data
desc}
\end{
member
desc}
\begin{
datadesc}
{
name
}
\begin{
memberdesc}
[file]
{
name
}
If the file object was created using
\function
{
open()
}
, the name of
the file. Otherwise, some string that indicates the source of the
file object, of the form
\samp
{
<
\mbox
{
\ldots
}
>
}
. This is a read-only
attribute.
\end{
data
desc}
\end{
member
desc}
\begin{
datadesc}
{
softspace
}
\begin{
memberdesc}
[file]
{
softspace
}
Boolean that indicates whether a space character needs to be printed
before another value when using the
\keyword
{
print
}
statement.
Classes that are trying to simulate a file object should also have a
...
...
@@ -829,7 +827,7 @@ writable \code{softspace} attribute, which should be initialized to
zero. This will be automatic for classes implemented in Python; types
implemented in
\C
{}
will have to provide a writable
\code
{
softspace
}
attribute.
\end{
data
desc}
\end{
member
desc}
\subsubsection
{
Internal Objects
}
...
...
Doc/libformatter.tex
View file @
8fe533e6
This diff is collapsed.
Click to expand it.
Doc/libhtmllib.tex
View file @
8fe533e6
...
...
@@ -70,53 +70,50 @@ handlers for all HTML 2.0 and many HTML 3.0 and 3.2 elements.
In addition to tag methods, the
\class
{
HTMLParser
}
class provides some
additional methods and instance variables for use within tag methods.
\setindexsubitem
{
(HTMLParser attribute)
}
\begin{datadesc}
{
formatter
}
\begin{memberdesc}
{
formatter
}
This is the formatter instance associated with the parser.
\end{
data
desc}
\end{
member
desc}
\begin{
data
desc}
{
nofill
}
\begin{
member
desc}
{
nofill
}
Boolean flag which should be true when whitespace should not be
collapsed, or false when it should be. In general, this should only
be true when character data is to be treated as ``preformatted'' text,
as within a
\code
{
<PRE>
}
element. The default value is false. This
affects the operation of
\method
{
handle
_
data()
}
and
\method
{
save
_
end()
}
.
\end{
data
desc}
\end{
member
desc}
\setindexsubitem
{
(HTMLParser method)
}
\begin{
func
desc}
{
anchor
_
bgn
}{
href, name, type
}
\begin{
method
desc}
{
anchor
_
bgn
}{
href, name, type
}
This method is called at the start of an anchor region. The arguments
correspond to the attributes of the
\code
{
<A>
}
tag with the same
names. The default implementation maintains a list of hyperlinks
(defined by the
\code
{
href
}
attribute) within the document. The list
of hyperlinks is available as the data attribute
\code
{
anchorlist
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
anchor
_
end
}{}
\begin{
method
desc}
{
anchor
_
end
}{}
This method is called at the end of an anchor region. The default
implementation adds a textual footnote marker using an index into the
list of hyperlinks created by
\method
{
anchor
_
bgn()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
handle
_
image
}{
source, alt
\optional
{
, ismap
\optional
{
, align
\optional
{
, width
\optional
{
, height
}}}}}
\begin{
method
desc}
{
handle
_
image
}{
source, alt
\optional
{
, ismap
\optional
{
, align
\optional
{
, width
\optional
{
, height
}}}}}
This method is called to handle images. The default implementation
simply passes the
\var
{
alt
}
value to the
\method
{
handle
_
data()
}
method.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
save
_
bgn
}{}
\begin{
method
desc}
{
save
_
bgn
}{}
Begins saving character data in a buffer instead of sending it to the
formatter object. Retrieve the stored data via
\method
{
save
_
end()
}
.
Use of the
\method
{
save
_
bgn()
}
/
\method
{
save
_
end()
}
pair may not be
nested.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
save
_
end
}{}
\begin{
method
desc}
{
save
_
end
}{}
Ends buffering character data and returns all data saved since the
preceeding call to
\method
{
save
_
bgn()
}
. If the
\code
{
nofill
}
flag is
false, whitespace is collapsed to single spaces. A call to this
method without a preceeding call to
\method
{
save
_
bgn()
}
will raise a
\exception
{
TypeError
}
exception.
\end{
func
desc}
\end{
method
desc}
Doc/libpprint.tex
View file @
8fe533e6
...
...
@@ -142,32 +142,31 @@ l/lib/python1.4/test', '/usr/local/lib/python1.4/sunos5', '/usr/local/lib/python
\class
{
PrettyPrinter
}
instances have the following methods:
\setindexsubitem
{
(PrettyPrinter method)
}
\begin{
func
desc}
{
pformat
}{
object
}
\begin{
method
desc}
{
pformat
}{
object
}
Return the formatted representation of
\var
{
object
}
. This takes into
a
ccount the options passed to the
\class
{
PrettyPrinter
}
constructor.
\end{
func
desc}
A
ccount the options passed to the
\class
{
PrettyPrinter
}
constructor.
\end{
method
desc}
\begin{
func
desc}
{
pprint
}{
object
}
\begin{
method
desc}
{
pprint
}{
object
}
Print the formatted representation of
\var
{
object
}
on the configured
stream, followed by a newline.
\end{
func
desc}
\end{
method
desc}
The following methods provide the implementations for the
corresponding functions of the same names. Using these methods on an
instance is slightly more efficient since new
\class
{
PrettyPrinter
}
objects don't need to be created.
\begin{
func
desc}
{
isreadable
}{
object
}
\begin{
method
desc}
{
isreadable
}{
object
}
Determine if the formatted representation of the object is
``readable,'' or can be used to reconstruct the value using
\function
{
eval()
}
\bifuncindex
{
eval
}
. Note that this returns false for
recursive objects. If the
\var
{
depth
}
parameter of the
\class
{
PrettyPrinter
}
is set and the object is deeper than allowed,
this returns false.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
isrecursive
}{
object
}
\begin{
method
desc}
{
isrecursive
}{
object
}
Determine if the object requires a recursive representation.
\end{
func
desc}
\end{
method
desc}
Doc/libprofile.tex
View file @
8fe533e6
\chapter
{
The Python Profiler
}
\label
{
profile
}
\stmodindex
{
profile
}
\stmodindex
{
pstats
}
Copyright
\copyright
{}
1994, by InfoSeek Corporation, all rights reserved.
...
...
@@ -256,8 +254,9 @@ of algorithms to be directly compared to iterative implementations.
\section
{
Reference Manual
}
\stmodindex
{
profile
}
\label
{
module-profile
}
\setindexsubitem
{
(in module profile)
}
The primary entry point for the profiler is the global function
\function
{
profile.run()
}
. It is typically used to create any profile
...
...
@@ -269,7 +268,7 @@ Profiler Extensions, which includes discussion of how to derive
``better'' profilers from the classes presented, or reading the source
code for these modules.
\begin{funcdesc}
{
profile.
run
}{
string
\optional
{
, filename
\optional
{
, ...
}}}
\begin{funcdesc}
{
run
}{
string
\optional
{
, filename
\optional
{
, ...
}}}
This function takes a single argument that has can be passed to the
\keyword
{
exec
}
statement, and an optional file name. In all cases this
...
...
@@ -336,7 +335,8 @@ printed.
Analysis of the profiler data is done using this class from the
\module
{
pstats
}
module:
\setindexsubitem
{
(in module pstats)
}
% now switch modules....
\stmodindex
{
pstats
}
\begin{classdesc}
{
Stats
}{
filename
\optional
{
, ...
}}
This class constructor creates an instance of a ``statistics object''
...
...
@@ -361,7 +361,7 @@ need to be combined with data in an existing \class{Stats} object, the
\setindexsubitem
{
(Stats method)
}
\begin{
func
desc}
{
strip
_
dirs
}{}
\begin{
method
desc}
{
strip
_
dirs
}{}
This method for the
\class
{
Stats
}
class removes all leading path
information from file names. It is very useful in reducing the size
of the printout to fit within (close to) 80 columns. This method
...
...
@@ -372,19 +372,19 @@ initialization and loading. If \method{strip_dirs()} causes two
function names to be indistinguishable (i.e., they are on the same
line of the same filename, and have the same function name), then the
statistics for these two entries are accumulated into a single entry.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
add
}{
filename
\optional
{
, ...
}}
\begin{
method
desc}
{
add
}{
filename
\optional
{
, ...
}}
This method of the
\class
{
Stats
}
class accumulates additional
profiling information into the current profiling object. Its
arguments should refer to filenames created by the corresponding
version of
\function
{
profile.run()
}
. Statistics for identically named
(re: file, line, name) functions are automatically accumulated into
single function statistics.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
sort
_
stats
}{
key
\optional
{
, ...
}}
\begin{
method
desc}
{
sort
_
stats
}{
key
\optional
{
, ...
}}
This method modifies the
\class
{
Stats
}
object by sorting it according
to the supplied criteria. The argument is typically a string
identifying the basis of a sort (example:
\code
{
"time"
}
or
...
...
@@ -430,18 +430,18 @@ interpreted as \code{"stdname"}, \code{"calls"}, \code{"time"}, and
\code
{
"cumulative"
}
respectively. If this old style format (numeric)
is used, only one sort key (the numeric key) will be used, and
additional arguments will be silently ignored.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
reverse
_
order
}{}
\begin{
method
desc}
{
reverse
_
order
}{}
This method for the
\class
{
Stats
}
class reverses the ordering of the basic
list within the object. This method is provided primarily for
compatibility with the old profiler. Its utility is questionable
now that ascending vs descending order is properly selected based on
the sort key of choice.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
print
_
stats
}{
restriction
\optional
{
, ...
}}
\begin{
method
desc}
{
print
_
stats
}{
restriction
\optional
{
, ...
}}
This method for the
\class
{
Stats
}
class prints out a report as described
in the
\function
{
profile.run()
}
definition.
...
...
@@ -473,10 +473,10 @@ print_stats("foo:", .1)
would limit the list to all functions having file names
\samp
{
.*foo:
}
,
and then proceed to only print the first 10
\%
of them.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
print
_
callers
}{
restrictions
\optional
{
, ...
}}
\begin{
method
desc}
{
print
_
callers
}{
restrictions
\optional
{
, ...
}}
This method for the
\class
{
Stats
}
class prints a list of all functions
that called each function in the profiled database. The ordering is
identical to that provided by
\method
{
print
_
stats()
}
, and the definition
...
...
@@ -484,16 +484,16 @@ of the restricting argument is also identical. For convenience, a
number is shown in parentheses after each caller to show how many
times this specific call was made. A second non-parenthesized number
is the cumulative time spent in the function at the right.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
print
_
callees
}{
restrictions
\optional
{
, ...
}}
\begin{
method
desc}
{
print
_
callees
}{
restrictions
\optional
{
, ...
}}
This method for the
\class
{
Stats
}
class prints a list of all function
that were called by the indicated function. Aside from this reversal
of direction of calls (re: called vs was called by), the arguments and
ordering are identical to the
\method
{
print
_
callers()
}
method.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
ignore
}{}
\begin{
method
desc}
{
ignore
}{}
This method of the
\class
{
Stats
}
class is used to dispose of the value
returned by earlier methods. All standard methods in this class
return the instance that is being processed, so that the commands can
...
...
@@ -503,7 +503,7 @@ be strung together. For example:
pstats.Stats('foofile').strip
_
dirs().sort
_
stats('cum')
\
.print
_
stats().ignore()
\end{verbatim}
%
would perform all the indicated functions, but it would not return
the final reference to the
\class
{
Stats
}
instance.
%
\footnote
{
...
...
@@ -511,7 +511,7 @@ This was once necessary, when Python would print any unused expression
result that was not
\code
{
None
}
. The method is still defined for
backward compatibility.
}
\end{
func
desc}
\end{
method
desc}
\section
{
Limitations
}
...
...
Doc/libqueue.tex
View file @
8fe533e6
...
...
@@ -37,34 +37,32 @@ other queue organizations (e.g. stack) but the inheritable interface
is not described here. See the source code for details. The public
methods are:
\setindexsubitem
{
(Queue method)
}
\begin{funcdesc}
{
qsize
}{}
\begin{methoddesc}
{
qsize
}{}
Returns the approximate size of the queue. Because of multithreading
semantics, this number is not reliable.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
empty
}{}
\begin{
method
desc}
{
empty
}{}
Returns
\code
{
1
}
if the queue is empty,
\code
{
0
}
otherwise. Because
of multithreading semantics, this is not reliable.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
full
}{}
\begin{
method
desc}
{
full
}{}
Returns
\code
{
1
}
if the queue is full,
\code
{
0
}
otherwise. Because of
multithreading semantics, this is not reliable.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
put
}{
item
}
\begin{
method
desc}
{
put
}{
item
}
Puts
\var
{
item
}
into the queue.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
get
}{}
\begin{
method
desc}
{
get
}{}
Gets and returns an item from the queue, blocking if necessary until
one is available.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
get
_
nowait
}{}
\begin{
method
desc}
{
get
_
nowait
}{}
Gets and returns an item from the queue if one is immediately
available. Raises an
\exception
{
Empty
}
exception if the queue is
empty or if the queue's emptiness cannot be determined.
\end{
func
desc}
\end{
method
desc}
Doc/libsgmllib.tex
View file @
8fe533e6
...
...
@@ -38,37 +38,36 @@ spaces, tabs, and newlines are allowed between the trailing
\class
{
SGMLParser
}
instances have the following interface methods:
\setindexsubitem
{
(SGMLParser method)
}
\begin{
func
desc}
{
reset
}{}
\begin{
method
desc}
{
reset
}{}
Reset the instance. Loses all unprocessed data. This is called
implicitly at instantiation time.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
setnomoretags
}{}
\begin{
method
desc}
{
setnomoretags
}{}
Stop processing tags. Treat all following input as literal input
(CDATA). (This is only provided so the HTML tag
\code
{
<PLAINTEXT>
}
can be implemented.)
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
setliteral
}{}
\begin{
method
desc}
{
setliteral
}{}
Enter literal mode (CDATA mode).
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
feed
}{
data
}
\begin{
method
desc}
{
feed
}{
data
}
Feed some text to the parser. It is processed insofar as it consists
of complete elements; incomplete data is buffered until more data is
fed or
\method
{
close()
}
is called.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
close
}{}
\begin{
method
desc}
{
close
}{}
Force processing of all buffered data as if it were followed by an
end-of-file mark. This method may be redefined by a derived class to
define additional processing at the end of the input, but the
redefined version should always call
\method
{
close()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
handle
_
starttag
}{
tag, method, attributes
}
\begin{
method
desc}
{
handle
_
starttag
}{
tag, method, attributes
}
This method is called to handle start tags for which either a
\code
{
start
_
\var
{
tag
}
()
}
or
\code
{
do
_
\var
{
tag
}
()
}
method has been
defined. The
\var
{
tag
}
argument is the name of the tag converted to
...
...
@@ -82,9 +81,9 @@ instance, for the tag \code{<A HREF="http://www.cwi.nl/">}, this
method would be called as
\samp
{
unknown
_
starttag('a', [('href',
'http://www.cwi.nl/')])
}
. The base implementation simply calls
\var
{
method
}
with
\var
{
attributes
}
as the only argument.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
handle
_
endtag
}{
tag, method
}
\begin{
method
desc}
{
handle
_
endtag
}{
tag, method
}
This method is called to handle endtags for which an
\code
{
end
_
\var
{
tag
}
()
}
method has been defined. The
\var
{
tag
}
argument is the name of the tag converted to lower case, and the
...
...
@@ -93,15 +92,15 @@ support semantic interpretation of the end tag. If no
\code
{
end
_
\var
{
tag
}
()
}
method is defined for the closing element,
this handler is not called. The base implementation simply calls
\var
{
method
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
handle
_
data
}{
data
}
\begin{
method
desc}
{
handle
_
data
}{
data
}
This method is called to process arbitrary data. It is intended to be
overridden by a derived class; the base class implementation does
nothing.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
handle
_
charref
}{
ref
}
\begin{
method
desc}
{
handle
_
charref
}{
ref
}
This method is called to process a character reference of the form
\samp
{
\&\#\var
{
ref
}
;
}
. In the base implementation,
\var
{
ref
}
must
be a decimal number in the
...
...
@@ -111,9 +110,9 @@ method \method{handle_data()} with the character as argument. If
\code
{
unknown
_
charref(
\var
{
ref
}
)
}
is called to handle the error. A
subclass must override this method to provide support for named
character entities.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
handle
_
entityref
}{
ref
}
\begin{
method
desc}
{
handle
_
entityref
}{
ref
}
This method is called to process a general entity reference of the
form
\samp
{
\&\var
{
ref
}
;
}
where
\var
{
ref
}
is an general entity
reference. It looks for
\var
{
ref
}
in the instance (or class)
...
...
@@ -124,46 +123,46 @@ with the translation; otherwise, it calls the method
\code
{
unknown
_
entityref(
\var
{
ref
}
)
}
. The default
\member
{
entitydefs
}
defines translations for
\code
{
\&
amp;
}
,
\code
{
\&
apos
}
,
\code
{
\&
gt;
}
,
\code
{
\&
lt;
}
, and
\code
{
\&
quot;
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
handle
_
comment
}{
comment
}
\begin{
method
desc}
{
handle
_
comment
}{
comment
}
This method is called when a comment is encountered. The
\var
{
comment
}
argument is a string containing the text between the
\samp
{
<!--
}
and
\samp
{
-->
}
delimiters, but not the delimiters
themselves. For example, the comment
\samp
{
<!--text-->
}
will
cause this method to be called with the argument
\code
{
'text'
}
. The
default method does nothing.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
report
_
unbalanced
}{
tag
}
\begin{
method
desc}
{
report
_
unbalanced
}{
tag
}
This method is called when an end tag is found which does not
correspond to any open element.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
unknown
_
starttag
}{
tag, attributes
}
\begin{
method
desc}
{
unknown
_
starttag
}{
tag, attributes
}
This method is called to process an unknown start tag. It is intended
to be overridden by a derived class; the base class implementation
does nothing.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
unknown
_
endtag
}{
tag
}
\begin{
method
desc}
{
unknown
_
endtag
}{
tag
}
This method is called to process an unknown end tag. It is intended
to be overridden by a derived class; the base class implementation
does nothing.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
unknown
_
charref
}{
ref
}
\begin{
method
desc}
{
unknown
_
charref
}{
ref
}
This method is called to process unresolvable numeric character
references. Refer to
\method
{
handle
_
charref()
}
to determine what is
handled by default. It is intended to be overridden by a derived
class; the base class implementation does nothing.
\end{
func
desc}
\end{
method
desc}
\begin{
func
desc}
{
unknown
_
entityref
}{
ref
}
\begin{
method
desc}
{
unknown
_
entityref
}{
ref
}
This method is called to process an unknown entity reference. It is
intended to be overridden by a derived class; the base class
implementation does nothing.
\end{
func
desc}
\end{
method
desc}
Apart from overriding or extending the methods listed above, derived
classes may also define methods of the following form to define
...
...
@@ -171,22 +170,22 @@ processing of specific tags. Tag names in the input stream are case
independent; the
\var
{
tag
}
occurring in method names must be in lower
case:
\begin{
func
descni}
{
start
_
\var
{
tag
}}{
attributes
}
\begin{
method
descni}
{
start
_
\var
{
tag
}}{
attributes
}
This method is called to process an opening tag
\var
{
tag
}
. It has
preference over
\code
{
do
_
\var
{
tag
}
()
}
. The
\var
{
attributes
}
argument has the same meaning as described for
\method
{
handle
_
starttag()
}
above.
\end{
func
descni}
\end{
method
descni}
\begin{
func
descni}
{
do
_
\var
{
tag
}}{
attributes
}
\begin{
method
descni}
{
do
_
\var
{
tag
}}{
attributes
}
This method is called to process an opening tag
\var
{
tag
}
that does
not come with a matching closing tag. The
\var
{
attributes
}
argument
has the same meaning as described for
\method
{
handle
_
starttag()
}
above.
\end{
func
descni}
\end{
method
descni}
\begin{
func
descni}
{
end
_
\var
{
tag
}}{}
\begin{
method
descni}
{
end
_
\var
{
tag
}}{}
This method is called to process a closing tag
\var
{
tag
}
.
\end{
func
descni}
\end{
method
descni}
Note that the parser maintains a stack of open elements for which no
end tag has been found yet. Only tags processed by
...
...
Doc/libstrio.tex
View file @
8fe533e6
...
...
@@ -3,15 +3,21 @@
\stmodindex
{
StringIO
}
This module implements a file-like class,
\c
ode
{
StringIO
}
,
This module implements a file-like class,
\c
lass
{
StringIO
}
,
that reads and writes a string buffer (also known as
\emph
{
memory
files
}
). See the description on file objects for operations.
When a
\code
{
StringIO
}
object is created, it can be initialized
\begin{classdesc}
{
StringIO
}{
\optional
{
buffer
}}
When a
\class
{
StringIO
}
object is created, it can be initialized
to an existing string by passing the string to the constructor.
If no string is given, the
\code
{
StringIO
}
will start empty.
If no string is given, the
\class
{
StringIO
}
will start empty.
\end{classdesc}
The method
\code
{
getvalue()
}
can be called to retrieve the entire
contents of the ``file'' at any time before the
\code
{
StringIO
}
object's
\code
{
close()
}
method is called. Calling
\code
{
close()
}
will
free the memory buffer.
\begin{methoddesc}
{
getvalue
}{}
Retrieve the entire contents of the ``file'' at any time before the
\class
{
StringIO
}
object's
\method
{
close()
}
method is called.
\end{methoddesc}
\begin{methoddesc}
{
close
}{}
Free the memory buffer.
\end{methoddesc}
Doc/libtypes.tex
View file @
8fe533e6
...
...
@@ -707,30 +707,28 @@ device or writing a file opened for reading.
Files have the following methods:
\setindexsubitem
{
(file method)
}
\begin{funcdesc}
{
close
}{}
\begin{methoddesc}
[file]
{
close
}{}
Close the file. A closed file cannot be read or written anymore.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
flush
}{}
\begin{
methoddesc}
[file]
{
flush
}{}
Flush the internal buffer, like
\code
{
stdio
}
's
\code
{
fflush()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
isatty
}{}
\begin{
methoddesc}
[file]
{
isatty
}{}
Return
\code
{
1
}
if the file is connected to a tty(-like) device, else
\code
{
0
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
fileno
}{}
\begin{
methoddesc}
[file]
{
fileno
}{}
Return the integer ``file descriptor'' that is used by the underlying
implementation to request I/O operations from the operating system.
This can be useful for other, lower level interfaces that use file
descriptors, e.g. module
\code
{
fcntl
}
or
\code
{
os.read()
}
and friends.
\refbimodindex
{
fcntl
}
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
read
}{
\optional
{
size
}}
\begin{
methoddesc}
[file]
{
read
}{
\optional
{
size
}}
Read at most
\var
{
size
}
bytes from the file (less if the read hits
\EOF
{}
or no more data is immediately available on a pipe, tty or
similar device). If the
\var
{
size
}
argument is negative or omitted,
...
...
@@ -738,9 +736,9 @@ descriptors, e.g. module \code{fcntl} or \code{os.read()} and friends.
object. An empty string is returned when
\EOF
{}
is encountered
immediately. (For certain files, like ttys, it makes sense to
continue reading after an
\EOF
{}
is hit.)
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
readline
}{
\optional
{
size
}}
\begin{
methoddesc}
[file]
{
readline
}{
\optional
{
size
}}
Read one entire line from the file. A trailing newline character is
kept in the string
%
\footnote
{
The advantage of leaving the newline on is that an empty string
...
...
@@ -757,71 +755,71 @@ descriptors, e.g. module \code{fcntl} or \code{os.read()} and friends.
immediately. Note: unlike
\code
{
stdio
}
's
\code
{
fgets()
}
, the returned
string contains null characters (
\code
{
'
\e
0'
}
) if they occurred in the
input.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
readlines
}{
\optional
{
sizehint
}}
\begin{
methoddesc}
[file]
{
readlines
}{
\optional
{
sizehint
}}
Read until
\EOF
{}
using
\code
{
readline()
}
and return a list containing
the lines thus read. If the optional
\var
{
sizehint
}
argument is
present, instead of reading up to
\EOF
{}
, whole lines totalling
approximately
\var
{
sizehint
}
bytes (possibly after rounding up to an
internal buffer size) are read.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
seek
}{
offset, whence
}
\begin{
methoddesc}
[file]
{
seek
}{
offset, whence
}
Set the file's current position, like
\code
{
stdio
}
's
\code
{
fseek()
}
.
The
\var
{
whence
}
argument is optional and defaults to
\code
{
0
}
(absolute file positioning); other values are
\code
{
1
}
(seek
relative to the current position) and
\code
{
2
}
(seek relative to the
file's end). There is no return value.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
tell
}{}
\begin{
methoddesc}
[file]
{
tell
}{}
Return the file's current position, like
\code
{
stdio
}
's
\code
{
ftell()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
truncate
}{
\optional
{
size
}}
\begin{
methoddesc}
[file]
{
truncate
}{
\optional
{
size
}}
Truncate the file's size. If the optional size argument present, the
file is truncated to (at most) that size. The size defaults to the
current position. Availability of this function depends on the
operating system version (e.g., not all
\UNIX
{}
versions support this
operation).
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
write
}{
str
}
\begin{
methoddesc}
[file]
{
write
}{
str
}
Write a string to the file. There is no return value. Note: due to
buffering, the string may not actually show up in the file until
the
\code
{
flush()
}
or
\code
{
close()
}
method is called.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
writelines
}{
list
}
\begin{
methoddesc}
[file]
{
writelines
}{
list
}
Write a list of strings to the file. There is no return value.
(The name is intended to match
\code
{
readlines
}
;
\code
{
writelines
}
does not add line separators.)
\end{
func
desc}
\end{
method
desc}
File objects also offer the following attributes:
\setindexsubitem
{
(file attribute)
}
\begin{
datadesc}
{
closed
}
\begin{
memberdesc}
[file]
{
closed
}
Boolean indicating the current state of the file object. This is a
read-only attribute; the
\method
{
close()
}
method changes the value.
\end{
data
desc}
\end{
member
desc}
\begin{
datadesc}
{
mode
}
\begin{
memberdesc}
[file]
{
mode
}
The I/O mode for the file. If the file was created using the
\function
{
open()
}
built-in function, this will be the value of the
\var
{
mode
}
parameter. This is a read-only attribute.
\end{
data
desc}
\end{
member
desc}
\begin{
datadesc}
{
name
}
\begin{
memberdesc}
[file]
{
name
}
If the file object was created using
\function
{
open()
}
, the name of
the file. Otherwise, some string that indicates the source of the
file object, of the form
\samp
{
<
\mbox
{
\ldots
}
>
}
. This is a read-only
attribute.
\end{
data
desc}
\end{
member
desc}
\begin{
datadesc}
{
softspace
}
\begin{
memberdesc}
[file]
{
softspace
}
Boolean that indicates whether a space character needs to be printed
before another value when using the
\keyword
{
print
}
statement.
Classes that are trying to simulate a file object should also have a
...
...
@@ -829,7 +827,7 @@ writable \code{softspace} attribute, which should be initialized to
zero. This will be automatic for classes implemented in Python; types
implemented in
\C
{}
will have to provide a writable
\code
{
softspace
}
attribute.
\end{
data
desc}
\end{
member
desc}
\subsubsection
{
Internal Objects
}
...
...
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