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
e8803e75
Commit
e8803e75
authored
Nov 20, 2010
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #8340: document bytearray in Python 2.7.
parent
bbd72509
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
10 deletions
+41
-10
Doc/library/functions.rst
Doc/library/functions.rst
+26
-0
Doc/library/stdtypes.rst
Doc/library/stdtypes.rst
+15
-10
No files found.
Doc/library/functions.rst
View file @
e8803e75
...
...
@@ -78,6 +78,32 @@ available. They are listed here in alphabetical order.
If no argument is given, this function returns :const:`False`.
.. function:: bytearray([source[, encoding[, errors]]])
Return a new array of bytes. The :class:`bytearray` type is a mutable
sequence of integers in the range 0 <= x < 256. It has most of the usual
methods of mutable sequences, described in :ref:`typesseq-mutable`, as well
as most methods that the :class:`str` type has, see :ref:`string-methods`.
The optional *source* 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:`bytearray` then converts the string to
bytes using :meth:`str.encode`.
* If it is an *integer*, the array will have that size and will be
initialized with null bytes.
* If it is an object conforming to the *buffer* interface, a read-only buffer
of the object will be used to initialize the bytes array.
* If it is an *iterable*, it must be an iterable of integers in the range
``0 <= x < 256``, which are used as the initial contents of the array.
Without an argument, an array of size 0 is created.
.. function:: callable(object)
Return :const:`True` if the *object* argument appears callable,
...
...
Doc/library/stdtypes.rst
View file @
e8803e75
...
...
@@ -659,11 +659,11 @@ yield expression <yieldexpr>`.
.. _typesseq:
Sequence Types --- :class:`str`, :class:`unicode`, :class:`list`, :class:`tuple`, :class:`buffer`, :class:`xrange`
==================================================================================================================
Sequence Types --- :class:`str`, :class:`unicode`, :class:`list`, :class:`tuple`, :class:`b
ytearray`, :class:`b
uffer`, :class:`xrange`
==================================================================================================================
====================
There are s
ix sequence types: strings, Unicode strings, lists, tuples, buffer
s,
and xrange objects.
There are s
even sequence types: strings, Unicode strings, lists, tuple
s,
bytearrays, buffers,
and xrange objects.
For other containers see the built in :class:`dict` and :class:`set` classes,
and the :mod:`collections` module.
...
...
@@ -675,6 +675,7 @@ and the :mod:`collections` module.
object: Unicode
object: tuple
object: list
object: bytearray
object: buffer
object: xrange
...
...
@@ -690,6 +691,8 @@ 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,)``.
Bytearray objects are created with the built-in function :func:`bytearray`.
Buffer objects are not directly supported by Python syntax, but can be created
by calling the built-in function :func:`buffer`. They don't support
concatenation or repetition.
...
...
@@ -834,7 +837,8 @@ String Methods
.. index:: pair: string; methods
Below are listed the string methods which both 8-bit strings and
Unicode objects support.
Unicode objects support. Some of them are also available on :class:`bytearray`
objects.
In addition, Python's strings support the sequence type methods
described in the :ref:`typesseq` section. To output formatted strings
...
...
@@ -1505,11 +1509,12 @@ Mutable Sequence Types
triple: mutable; sequence; types
object: list
List 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):
List and :class:`bytearray` 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):
.. index::
triple: operations on; sequence; types
...
...
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