Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
6dbd382e
Kaydet (Commit)
6dbd382e
authored
Şub 28, 2001
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Clean up some of the markup for consistency, wrap some long lines.
üst
bca60c07
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
45 deletions
+50
-45
libinspect.tex
Doc/lib/libinspect.tex
+50
-45
No files found.
Doc/lib/libinspect.tex
Dosyayı görüntüle @
6dbd382e
\section
{
\module
{
inspect
}
---
Inspect live objects
}
\declaremodule
{
standard
}{
inspect
}
\modulesynopsis
{
Extract information and source code from live objects.
}
\index
{
inspect
}
\moduleauthor
{
Ka-Ping Yee
}{
ping@lfw.org
}
\sectionauthor
{
Ka-Ping Yee
}{
ping@lfw.org
}
\versionadded
{
2.1
}
The
\
cod
e
{
inspect
}
module provides several useful functions
The
\
modul
e
{
inspect
}
module provides several useful functions
to help get information about live objects such as modules,
classes, methods, functions, tracebacks, frame objects, and
code objects. For example, it can help you examine the
...
...
@@ -31,19 +33,16 @@ you can expect to find the following special attributes:
\begin{tableiii}
{
c|l|l
}{}{
Type
}{
Attribute
}{
Description
}
\lineiii
{
module
}{__
doc
__}{
documentation string
}
\lineiii
{}{__
file
__}{
filename (missing for built-in modules)
}
\lineiii
{}{}{}
\hline
\lineiii
{
class
}{__
doc
__}{
documentation string
}
\lineiii
{}{__
module
__}{
name of module in which this class was defined
}
\lineiii
{}{}{}
\hline
\lineiii
{
method
}{__
doc
__}{
documentation string
}
\lineiii
{}{__
name
__}{
name with which this method was defined
}
\lineiii
{}{
im
_
class
}{
class object in which this method belongs
}
\lineiii
{}{
im
_
func
}{
function object containing implementation of method
}
\lineiii
{}{
im
_
self
}{
instance to which this method is bound, or
\code
{
None
}}
\lineiii
{}{}{}
\hline
\lineiii
{
function
}{__
doc
__}{
documentation string
}
\lineiii
{}{__
name
__}{
name with which this function was defined
}
\lineiii
{}{
func
_
code
}{
code object containing compiled function bytecode
}
...
...
@@ -51,14 +50,12 @@ you can expect to find the following special attributes:
\lineiii
{}{
func
_
doc
}{
(same as
__
doc
__
)
}
\lineiii
{}{
func
_
globals
}{
global namespace in which this function was defined
}
\lineiii
{}{
func
_
name
}{
(same as
__
name
__
)
}
\lineiii
{}{}{}
\hline
\lineiii
{
traceback
}{
tb
_
frame
}{
frame object at this level
}
\lineiii
{}{
tb
_
lasti
}{
index of last attempted instruction in bytecode
}
\lineiii
{}{
tb
_
lineno
}{
current line number in Python source code
}
\lineiii
{}{
tb
_
next
}{
next inner traceback object (called by this level)
}
\lineiii
{}{}{}
\hline
\lineiii
{
frame
}{
f
_
back
}{
next outer frame object (this frame's caller)
}
\lineiii
{}{
f
_
builtins
}{
built-in namespace seen by this frame
}
\lineiii
{}{
f
_
code
}{
code object being executed in this frame
}
...
...
@@ -71,8 +68,7 @@ you can expect to find the following special attributes:
\lineiii
{}{
f
_
locals
}{
local namespace seen by this frame
}
\lineiii
{}{
f
_
restricted
}{
0 or 1 if frame is in restricted execution mode
}
\lineiii
{}{
f
_
trace
}{
tracing function for this frame, or
\code
{
None
}}
\lineiii
{}{}{}
\hline
\lineiii
{
code
}{
co
_
argcount
}{
number of arguments (not including * or ** args)
}
\lineiii
{}{
co
_
code
}{
string of raw compiled bytecode
}
\lineiii
{}{
co
_
consts
}{
tuple of constants used in the bytecode
}
...
...
@@ -85,8 +81,7 @@ you can expect to find the following special attributes:
\lineiii
{}{
co
_
nlocals
}{
number of local variables
}
\lineiii
{}{
co
_
stacksize
}{
virtual machine stack space required
}
\lineiii
{}{
co
_
varnames
}{
tuple of names of arguments and local variables
}
\lineiii
{}{}{}
\hline
\lineiii
{
builtin
}{__
doc
__}{
documentation string
}
\lineiii
{}{__
name
__}{
original name of this function or method
}
\lineiii
{}{__
self
__}{
instance to which a method is bound, or
\code
{
None
}}
...
...
@@ -151,9 +146,9 @@ you can expect to find the following special attributes:
\end{funcdesc}
\begin{funcdesc}
{
getfile
}{
object
}
Return the name of the (text or binary) file in which an object was
defined.
This will fail with a TypeError if the object is a built-in module,
class, or function.
Return the name of the (text or binary) file in which an object was
defined. This will fail with a
\exception
{
TypeError
}
if the object
is a built-in module,
class, or function.
\end{funcdesc}
\begin{funcdesc}
{
getmodule
}{
object
}
...
...
@@ -161,9 +156,9 @@ you can expect to find the following special attributes:
\end{funcdesc}
\begin{funcdesc}
{
getsourcefile
}{
object
}
Return the name of the Python source file in which an object was
defined.
This will fail with a TypeError if the object is a built-in module,
class, or function.
Return the name of the Python source file in which an object was
defined. This will fail with a
\exception
{
TypeError
}
if the object
is a built-in module,
class, or function.
\end{funcdesc}
\begin{funcdesc}
{
getsourcelines
}{
object
}
...
...
@@ -171,15 +166,15 @@ you can expect to find the following special attributes:
The argument may be a module, class, method, function, traceback, frame,
or code object. The source code is returned as a list of the lines
corresponding to the object and the line number indicates where in the
original source file the first line of code was found. An
IOError is
raised if the source code cannot be retrieved.
original source file the first line of code was found. An
\exception
{
IOError
}
is
raised if the source code cannot be retrieved.
\end{funcdesc}
\begin{funcdesc}
{
getsource
}{
object
}
Return the text of the source code for an object.
The argument may be a module, class, method, function, traceback, frame,
or code object. The source code is returned as a single string. An
IOError
is raised if the source code cannot be retrieved.
\exception
{
IOError
}
is raised if the source code cannot be retrieved.
\end{funcdesc}
\subsection
{
Classes and functions
...
...
@@ -197,10 +192,11 @@ you can expect to find the following special attributes:
\begin{funcdesc}
{
getargspec
}{
func
}
Get the names and default values of a function's arguments.
A tuple of four things is returned: (args, varargs, varkw, defaults).
A tuple of four things is returned:
\code
{
(
\var
{
args
}
,
\var
{
varargs
}
,
\var
{
varkw
}
,
\var
{
defaults
}
)
}
.
\var
{
args
}
is a list of the argument names (it may contain nested lists).
\var
{
varargs
}
and
\var
{
varkw
}
are the names of the
* and ** arguments or
\code
{
None
}
.
\var
{
varargs
}
and
\var
{
varkw
}
are the names of the
\code
{
*
}
and
\code
{
**
}
arguments or
\code
{
None
}
.
\var
{
defaults
}
is a tuple of default argument values; if this tuple
has
\var
{
n
}
elements, they correspond to the last
\var
{
n
}
elements
listed in
\var
{
args
}
.
...
...
@@ -208,31 +204,36 @@ you can expect to find the following special attributes:
\begin{funcdesc}
{
getargvalues
}{
frame
}
Get information about arguments passed into a particular frame.
A tuple of four things is returned: (args, varargs, varkw, locals).
\var
{
args
}
is a list of the argument names (it may contain nested lists).
\var
{
varargs
}
and
\var
{
varkw
}
are the names of the * and ** arguments or
\code
{
None
}
.
A tuple of four things is returned:
\code
{
(
\var
{
args
}
,
\var
{
varargs
}
,
\var
{
varkw
}
,
\var
{
locals
}
)
}
.
\var
{
args
}
is a list of the argument names (it may contain nested
lists).
\var
{
varargs
}
and
\var
{
varkw
}
are the names of the
\code
{
*
}
and
\code
{
**
}
arguments or
\code
{
None
}
.
\var
{
locals
}
is the locals dictionary of the given frame.
\end{funcdesc}
\begin{funcdesc}
{
formatargspec
}{
args
\optional
{
, varargs, varkw, defaults,
argformat, varargsformat, varkwformat, defaultformat
}}
Format a pretty argument spec from the four values returned by getargspec.
The other four arguments are the corresponding optional formatting functions
that are called to turn names and values into strings.
argformat, varargsformat, varkwformat, defaultformat
}}
Format a pretty argument spec from the four values returned by
\function
{
getargspec()
}
. The other four arguments are the
corresponding optional formatting functions that are called to turn
names and values into strings.
\end{funcdesc}
\begin{funcdesc}
{
formatargvalues
}{
args
\optional
{
, varargs, varkw, locals,
argformat, varargsformat, varkwformat, valueformat
}}
Format a pretty argument spec from the four values returned by getargvalues.
The other four arguments are the corresponding optional formatting functions
that are called to turn names and values into strings.
argformat, varargsformat, varkwformat, valueformat
}}
Format a pretty argument spec from the four values returned by
\function
{
getargvalues()
}
. The other four arguments are the
corresponding optional formatting functions that are called to turn
names and values into strings.
\end{funcdesc}
\subsection
{
The interpreter stack
\label
{
inspect-stack
}}
When the following functions return ``frame records
'',
each record
When the following functions return ``frame records
,''
each record
is a tuple of six items: the frame object, the filename,
the line number of the current line, the function name, a list of
lines of context from the source code, and the index of the current
...
...
@@ -241,11 +242,13 @@ The optional \var{context} argument specifies the number of lines of
context to return, which are centered around the current line.
\begin{funcdesc}
{
getouterframes
}{
frame
\optional
{
, context
}}
Get a list of frame records for a frame and all higher (calling) frames.
Get a list of frame records for a frame and all higher (calling)
frames.
\end{funcdesc}
\begin{funcdesc}
{
getinnerframes
}{
traceback
\optional
{
, context
}}
Get a list of frame records for a traceback's frame and all lower frames.
Get a list of frame records for a traceback's frame and all lower
frames.
\end{funcdesc}
\begin{funcdesc}
{
currentframe
}{}
...
...
@@ -253,9 +256,11 @@ context to return, which are centered around the current line.
\end{funcdesc}
\begin{funcdesc}
{
stack
}{
\optional
{
context
}}
Return a list of frame records for the stack above the caller's frame.
Return a list of frame records for the stack above the caller's
frame.
\end{funcdesc}
\begin{funcdesc}
{
trace
}{
\optional
{
context
}}
Return a list of frame records for the stack below the current exception.
Return a list of frame records for the stack below the current
exception.
\end{funcdesc}
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