Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4785916

Browse files
committed
release() is probably not the most important method
1 parent fe7b405 commit 4785916

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

Doc/library/stdtypes.rst

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,6 +2313,24 @@ is generally interpreted as simple bytes.
23132313

23142314
:class:`memoryview` has several methods:
23152315

2316+
.. method:: tobytes()
2317+
2318+
Return the data in the buffer as a bytestring. This is equivalent to
2319+
calling the :class:`bytes` constructor on the memoryview. ::
2320+
2321+
>>> m = memoryview(b"abc")
2322+
>>> m.tobytes()
2323+
b'abc'
2324+
>>> bytes(m)
2325+
b'abc'
2326+
2327+
.. method:: tolist()
2328+
2329+
Return the data in the buffer as a list of integers. ::
2330+
2331+
>>> memoryview(b'abc').tolist()
2332+
[97, 98, 99]
2333+
23162334
.. method:: release()
23172335

23182336
Release the underlying buffer exposed by the memoryview object. Many
@@ -2346,24 +2364,6 @@ is generally interpreted as simple bytes.
23462364

23472365
.. versionadded:: 3.2
23482366

2349-
.. method:: tobytes()
2350-
2351-
Return the data in the buffer as a bytestring. This is equivalent to
2352-
calling the :class:`bytes` constructor on the memoryview. ::
2353-
2354-
>>> m = memoryview(b"abc")
2355-
>>> m.tobytes()
2356-
b'abc'
2357-
>>> bytes(m)
2358-
b'abc'
2359-
2360-
.. method:: tolist()
2361-
2362-
Return the data in the buffer as a list of integers. ::
2363-
2364-
>>> memoryview(b'abc').tolist()
2365-
[97, 98, 99]
2366-
23672367
There are also several readonly attributes available:
23682368

23692369
.. attribute:: format

0 commit comments

Comments
 (0)