diff --git a/README.md b/README.md index af086b4..87263ea 100644 --- a/README.md +++ b/README.md @@ -970,7 +970,7 @@ class MyClass: def get_class_name(cls): return cls.__name__ ``` -* **Return value of repr() should be unambiguous and of str() readable.** +* **Return value of str() should be readable and of repr() unambiguous.** * **If only repr() is defined, it will also be used for str().** * **Methods decorated with `'@staticmethod'` do not receive 'self' nor 'cls' as their first arg.** @@ -2038,11 +2038,17 @@ Array ```python from array import array +``` + +```python = array('', ) # Array from collection of numbers. = array('', ) # Array from bytes object. = array('', ) # Treats array as a sequence of numbers. -.fromfile(, n_items) # Appends items. Also frombytes(). - = bytes() # Or: .tobytes() +.fromfile(, n_items) # Appends items from the binary file. +``` + +```python + = bytes() # Converts array to a bytes object. .write() # Writes array to the binary file. ``` @@ -2071,10 +2077,9 @@ Memory View ``` ```python - = list() # Returns a list of ints or floats. - = str(, 'utf-8') # Treats mview as a bytes object. - = .hex() # Returns hex pairs. Accepts `sep=`. - = int.from_bytes(, …) # `byteorder='big/little', signed=False`. + = list() # Returns a list of ints or floats. + = str(, 'utf-8') # Treats mview as a bytes object. + = .hex() # Returns hex pairs. Accepts `sep=`. ``` diff --git a/index.html b/index.html index c700dba..fc1f589 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -818,7 +818,7 @@ player = Player(point, direction) #
    -
  • Return value of repr() should be unambiguous and of str() readable.
  • +
  • Return value of str() should be readable and of repr() unambiguous.
  • If only repr() is defined, it will also be used for str().
  • Methods decorated with '@staticmethod' do not receive 'self' nor 'cls' as their first arg.
@@ -1685,15 +1685,17 @@ CompletedProcess(args=['bc', #Array

List that can only hold numbers of a predefined type. Available types and their minimum sizes in bytes are listed above. Type sizes and byte order are always determined by the system, however bytes of each element can be swapped with byteswap() method.

from array import array
-<array> = array('<typecode>', <coll_of_nums>)  # Array from collection of numbers.
-<array> = array('<typecode>', <bytes>)         # Array from bytes object.
-<array> = array('<typecode>', <array>)         # Treats array as a sequence of numbers.
-<array>.fromfile(<file>, n_items)              # Appends items. Also frombytes().
-<bytes> = bytes(<array>)                       # Or: <array>.tobytes()
-<file>.write(<array>)                          # Writes array to the binary file.
 
+
<array> = array('<typecode>', <coll_of_nums>)  # Array from collection of numbers.
+<array> = array('<typecode>', <bytes>)         # Array from bytes object.
+<array> = array('<typecode>', <array>)         # Treats array as a sequence of numbers.
+<array>.fromfile(<file>, n_items)              # Appends items from the binary file.
+
+
<bytes> = bytes(<array>)                       # Converts array to a bytes object.
+<file>.write(<array>)                          # Writes array to the binary file.
+

#Memory View

  • A sequence object that points to the memory of another bytes-like object.
  • Each element can reference a single or multiple consecutive bytes, depending on format.
  • @@ -1713,10 +1715,9 @@ CompletedProcess(args=['bc', '<typecode>', <mview>) # Treats mview as a sequence of numbers. <file>.write(<mview>) # Writes mview to the binary file. -
    <list> = list(<mview>)                         # Returns a list of ints or floats.
    -<str>  = str(<mview>, 'utf-8')                 # Treats mview as a bytes object.
    -<str>  = <mview>.hex()                         # Returns hex pairs. Accepts `sep=<str>`.
    -<int>  = int.from_bytes(<mview>, …)            # `byteorder='big/little', signed=False`.
    +
    <list>  = list(<mview>)                        # Returns a list of ints or floats.
    +<str>   = str(<mview>, 'utf-8')                # Treats mview as a bytes object.
    +<str>   = <mview>.hex()                        # Returns hex pairs. Accepts `sep=<str>`.
     

    #Deque

    A thread-safe list with efficient appends and pops from either side. Pronounced "deck".

    from collections import deque
     <deque> = deque(<collection>)                  # Also `maxlen=None`.
    @@ -2936,7 +2937,7 @@ $ deactivate                  # Deactivates the activ