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
9541463a
Kaydet (Commit)
9541463a
authored
Kas 22, 2007
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Update docs for buffer -> bytearray rename.
üst
faddf1fb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
35 deletions
+34
-35
functions.rst
Doc/library/functions.rst
+8
-8
stdtypes.rst
Doc/library/stdtypes.rst
+26
-27
No files found.
Doc/library/functions.rst
Dosyayı görüntüle @
9541463a
...
...
@@ -118,18 +118,18 @@ available. They are listed here in alphabetical order.
..
index
::
pair
:
Boolean
;
type
..
function
::
b
uffer
([
arg
[,
encoding
[,
errors
]]])
..
function
::
b
ytearray
([
arg
[,
encoding
[,
errors
]]])
Return
a
new
array
of
bytes
.
The
:
class
:`
b
uffer
`
type
is
an
immutable
sequenc
e
of
integers
in
the
range
0
<=
x
<
256.
It
has
most
of
the
usual
methods
of
m
utable
sequences
,
described
in
:
ref
:`
typesseq
-
mutable
`,
as
well
as
most
methods
that
the
:
class
:`
str
`
type
has
,
see
:
ref
:`
bytes
-
methods
`.
Return
a
new
array
of
bytes
.
The
:
class
:`
b
ytearray
`
type
is
an
immutabl
e
sequence
of
integers
in
the
range
0
<=
x
<
256.
It
has
most
of
the
usual
m
ethods
of
mutable
sequences
,
described
in
:
ref
:`
typesseq
-
mutable
`,
as
well
as
most
methods
that
the
:
class
:`
str
`
type
has
,
see
:
ref
:`
bytes
-
methods
`.
The
optional
*
arg
*
parameter
can
be
used
to
initialize
the
array
in
a
few
different
ways
:
*
If
it
is
a
*
string
*,
you
must
also
give
the
*
encoding
*
(
and
optionally
,
*
errors
*)
parameters
;
:
func
:`
b
uffer
`
then
converts
the
Unicode
string
to
*
errors
*)
parameters
;
:
func
:`
b
ytearray
`
then
converts
the
Unicode
string
to
bytes
using
:
meth
:`
str
.
encode
`.
*
If
it
is
an
*
integer
*,
the
array
will
have
that
size
and
will
be
...
...
@@ -148,8 +148,8 @@ available. They are listed here in alphabetical order.
Return
a
new
"bytes"
object
,
which
is
an
immutable
sequence
of
integers
in
the
range
``
0
<=
x
<
256
``.
:
class
:`
bytes
`
is
an
immutable
version
of
:
class
:`
b
uffer
`
--
it
has
the
same
non
-
mutating
methods
and
the
same
indexing
and
slicing
behavior
.
:
class
:`
b
ytearray
`
--
it
has
the
same
non
-
mutating
methods
and
the
same
indexing
and
slicing
behavior
.
Accordingly
,
constructor
arguments
are
interpreted
as
for
:
func
:`
buffer
`.
...
...
Doc/library/stdtypes.rst
Dosyayı görüntüle @
9541463a
...
...
@@ -457,12 +457,12 @@ generator object) supplying the :meth:`__iter__` and :meth:`__next__` methods.
.. _typesseq:
Sequence Types --- :class:`str`, :class:`bytes`, :class:`b
uffer
`, :class:`list`, :class:`tuple`, :class:`range`
===============================================================================================================
Sequence Types --- :class:`str`, :class:`bytes`, :class:`b
ytearray
`, :class:`list`, :class:`tuple`, :class:`range`
===============================================================================================================
===
There are five sequence types: strings, byte sequences, b
uffers, lists, tuple
s,
and range objects. (For other containers see the built-in :class:`dict`,
:class:`list`, :class:`set`, and :class:`tuple` classes, and the
There are five sequence types: strings, byte sequences, b
yte arrays, list
s,
tuples, and range objects. (For other containers see the built-in
:class:`
dict`, :class:`
list`, :class:`set`, and :class:`tuple` classes, and the
:mod:`collections` module.)
.. index::
...
...
@@ -479,24 +479,24 @@ double quotes: ``'xyzzy'``, ``"frobozz"``. See :ref:`strings` for more about
string literals. In addition to the functionality described here, there are
also string-specific methods described in the :ref:`string-methods` section.
Bytes and b
uffer objects contain single bytes -- the former is immutable whi
le
the latter is a mutable sequence. Bytes objects can be constructed from
literals too; use a ``b`` prefix with normal string syntax: ``b'xyzzy'``.
To construct buffer objects, use the :func:`buffer
` function.
Bytes and b
ytearray objects contain single bytes -- the former is immutab
le
while
the latter is a mutable sequence. Bytes objects can be constructed from
literals too; use a ``b`` prefix with normal string syntax: ``b'xyzzy'``.
To
construct byte arrays, use the :func:`bytearray
` function.
.. warning::
While string objects are sequences of characters (represented by strings of
length 1), bytes and b
uffer
objects are sequences of *integers* (between 0
length 1), bytes and b
ytearray
objects are sequences of *integers* (between 0
and 255), representing the ASCII value of single bytes. That means that for
a bytes or b
uffer
object *b*, ``b[0]`` will be an integer, while ``b[0:1]``
will be a bytes or b
uffer
object of length 1.
a bytes or b
ytearray
object *b*, ``b[0]`` will be an integer, while ``b[0:1]``
will be a bytes or b
ytearray
object of length 1.
Also, while in previous Python versions, byte strings and Unicode strings
could be exchanged for each other rather freely (barring encoding issues),
strings and bytes are now completely separate concepts. There's no implicit
en-/decoding if you pass and object of the wrong type. A string always
compares unequal to a bytes or b
uffer
object.
compares unequal to a bytes or b
ytearray
object.
Lists are constructed with square brackets, separating items with commas: ``[a,
b, c]``. Tuples are constructed by the comma operator (not within square
...
...
@@ -504,10 +504,9 @@ brackets), with or without enclosing parentheses, but an empty tuple must have
the enclosing parentheses, such as ``a, b, c`` or ``()``. A single item tuple
must have a trailing comma, such as ``(d,)``.
Objects of type range are similar to buffers in that there is no specific syntax
to create them, but they are created using the :func:`range` function. They
don't support slicing, concatenation or repetition, and using ``in``, ``not
in``, :func:`min` or :func:`max` on them is inefficient.
Objects of type range are created using the :func:`range` function. They don't
support slicing, concatenation or repetition, and using ``in``, ``not in``,
:func:`min` or :func:`max` on them is inefficient.
Most sequence types support the following operations. The ``in`` and ``not in``
operations have the same priorities as the comparison operations. The ``+`` and
...
...
@@ -1168,16 +1167,16 @@ Mutable Sequence Types
.. index::
triple: mutable; sequence; types
object: list
object: b
uffer
object: b
ytearray
List and b
uffer
objects support additional operations that allow in-place
List and b
ytearray
objects support additional operations that allow in-place
modification of the object. Other mutable sequence types (when added to the
language) should also support these operations. Strings and tuples are
immutable sequence types: such objects cannot be modified once created. The
following operations are defined on mutable sequence types (where *x* is an
arbitrary object).
Note that while lists allow their items to be of any type, b
uffer
object
Note that while lists allow their items to be of any type, b
ytearray
object
"items" are all integers in the range 0 <= x < 256.
+------------------------------+--------------------------------+---------------------+
...
...
@@ -1271,7 +1270,7 @@ Notes:
sequence.
(7)
:meth:`sort` is not supported by
buffer
objects.
:meth:`sort` is not supported by
:class:`bytearray`
objects.
The :meth:`sort` method takes optional arguments for controlling the
comparisons.
...
...
@@ -1305,13 +1304,13 @@ Notes:
.. _bytes-methods:
Bytes and B
uffer
Methods
------------------------
Bytes and B
yte Array
Methods
------------------------
----
.. index:: pair: bytes; methods
pair: b
uffer
; methods
pair: b
ytearray
; methods
Bytes and b
uffer
objects, being "strings of bytes", have all methods found on
Bytes and b
ytearray
objects, being "strings of bytes", have all methods found on
strings, with the exception of :func:`encode`, :func:`format` and
:func:`isidentifier`, which do not make sense with these types. For converting
the objects to strings, they have a :func:`decode` method.
...
...
@@ -1321,7 +1320,7 @@ Wherever one of these methods needs to interpret the bytes as characters
.. note::
The methods on bytes and b
uffer
objects don't accept strings as their
The methods on bytes and b
ytearray
objects don't accept strings as their
arguments, just as the methods on strings don't accept bytes as their
arguments. For example, you have to write ::
...
...
@@ -1334,7 +1333,7 @@ Wherever one of these methods needs to interpret the bytes as characters
b = a.replace(b"a", b"f")
The bytes and b
uffer
types have an additional class method:
The bytes and b
ytearray
types have an additional class method:
.. method:: bytes.fromhex(string)
...
...
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