In Python, is the following the only way to get the number of elements?
arr.__len__()
If so, why the strange syntax?
Just use len(arr):
len(arr)
>>> import array >>> arr = array.array('i') >>> arr.append('2') >>> arr.__len__() 1 >>> len(arr) 1