array_construct.py 477 B

1234567891011121314151617181920
  1. # test construction of array.array from different objects
  2. try:
  3. from array import array
  4. except ImportError:
  5. print("SKIP")
  6. raise SystemExit
  7. # tuple, list
  8. print(array('b', (1, 2)))
  9. print(array('h', [1, 2]))
  10. # raw copy from bytes, bytearray
  11. print(array('h', b'22')) # should be byteorder-neutral
  12. print(array('h', bytearray(2)))
  13. print(array('i', bytearray(4)))
  14. # convert from other arrays
  15. print(array('H', array('b', [1, 2])))
  16. print(array('b', array('I', [1, 2])))