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
ee467d0a
Kaydet (Commit)
ee467d0a
authored
Şub 15, 2007
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch #1494140: Add documentation for the new struct.Struct object.
(backport from rev. 53785)
üst
d2bf6c0a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
0 deletions
+57
-0
libstruct.tex
Doc/lib/libstruct.tex
+55
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Doc/lib/libstruct.tex
Dosyayı görüntüle @
ee467d0a
...
...
@@ -29,6 +29,13 @@ The module defines the following exception and functions:
exactly.
\end{funcdesc}
\begin{funcdesc}
{
pack
_
into
}{
fmt, buffer, offset, v1, v2,
\moreargs
}
Pack the values
\code
{
\var
{
v1
}
,
\var
{
v2
}
,
\textrm
{
\ldots
}}
according to the given
format, write the packed bytes into the writable
\var
{
buffer
}
starting at
\var
{
offset
}
.
Note that the offset is not an optional argument.
\end{funcdesc}
\begin{funcdesc}
{
unpack
}{
fmt, string
}
Unpack the string (presumably packed by
\code
{
pack(
\var
{
fmt
}
,
\textrm
{
\ldots
}
)
}
) according to the given format. The result is a
...
...
@@ -37,6 +44,14 @@ The module defines the following exception and functions:
(
\code
{
len(
\var
{
string
}
)
}
must equal
\code
{
calcsize(
\var
{
fmt
}
)
}
).
\end{funcdesc}
\begin{funcdesc}
{
unpack
_
from
}{
fmt, buffer
\optional
{
,offset
\code
{
= 0
}}}
Unpack the
\var
{
buffer
}
according to tthe given format.
The result is a tuple even if it contains exactly one item. The
\var
{
buffer
}
must contain at least the amount of data required by the
format (
\code
{
len(buffer[offset:])
}
must be at least
\code
{
calcsize(
\var
{
fmt
}
)
}
).
\end{funcdesc}
\begin{funcdesc}
{
calcsize
}{
fmt
}
Return the size of the struct (and hence of the string)
corresponding to the given format.
...
...
@@ -195,3 +210,43 @@ in effect; standard size and alignment does not enforce any alignment.
\seemodule
{
array
}{
Packed binary storage of homogeneous data.
}
\seemodule
{
xdrlib
}{
Packing and unpacking of XDR data.
}
\end{seealso}
\subsection
{
Struct Objects
\label
{
struct-objects
}}
The
\module
{
struct
}
module also defines the following type:
\begin{classdesc}
{
Struct
}{
format
}
Return a new Struct object which writes and reads binary data according to
the format string
\var
{
format
}
. Creating a Struct object once and calling
its methods is more efficient than calling the
\module
{
struct
}
functions
with the same format since the format string only needs to be compiled once.
\versionadded
{
2.5
}
\end{classdesc}
Compiled Struct objects support the following methods and attributes:
\begin{methoddesc}
[Struct]
{
pack
}{
v1, v2,
\moreargs
}
Identical to the
\function
{
pack()
}
function, using the compiled format.
(
\code
{
len(result)
}
will equal
\member
{
self.size
}
.)
\end{methoddesc}
\begin{methoddesc}
[Struct]
{
pack
_
into
}{
buffer, offset, v1, v2,
\moreargs
}
Identical to the
\function
{
pack
_
into()
}
function, using the compiled format.
\end{methoddesc}
\begin{methoddesc}
[Struct]
{
unpack
}{
string
}
Identical to the
\function
{
unpack()
}
function, using the compiled format.
(
\code
{
len(string)
}
must equal
\member
{
self.size
}
).
\end{methoddesc}
\begin{methoddesc}
[Struct]
{
unpack
_
from
}{
buffer
\optional
{
,offset
\code
{
= 0
}}}
Identical to the
\function
{
unpack
_
from()
}
function, using the compiled format.
(
\code
{
len(buffer[offset:])
}
must be at least
\member
{
self.size
}
).
\end{methoddesc}
\begin{memberdesc}
[Struct]
{
format
}
The format string used to construct this Struct object.
\end{memberdesc}
Misc/NEWS
Dosyayı görüntüle @
ee467d0a
...
...
@@ -107,6 +107,8 @@ Core and builtins
Extension
Modules
-----------------
-
Patch
#
1494140
:
Add
documentation
for
the
new
struct
.
Struct
object
.
-
Patch
#
1657276
:
Make
NETLINK_DNRTMSG
conditional
.
-
Bug
#
1653736
:
Complain
about
keyword
arguments
to
time
.
isoformat
.
...
...
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