"""
Array Operations
"""
def array():
import array as arr
my_array = arr.array('i', [1, 2, 3, 4])
print(str(my_array))
array()
I am not sure what is wrong with the code as it works inside another class function.
Because you have a file called array.py
, when you write
import array
you're actually importing your file array.py
instead of the standard module array
. If you rename your array.py
file something else, you'll avoid this problem.