[10]
is a list literal. It creates a list with a single element, and that element is 10.
bytes()
behaves in several different ways depending on the argument, as you can see from its help()
documentation:
class bytes(object)
| bytes(iterable_of_ints) -> bytes
| bytes(string, encoding[, errors]) -> bytes
| bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer
| bytes(int) -> bytes object of size given by the parameter initialized with null bytes
| bytes() -> empty bytes object
|
| Construct an immutable array of bytes from:
| - an iterable yielding integers in range(256)
| - a text string encoded using the specified encoding
| - any object implementing the buffer API.
| - an integer
In this case, [10]
is used to invoke the bytes(iterable_of_ints)
behavior rather than the bytes(int)
behavior, despite only representing one byte.