Hello, I have an issue with uarray on pyboard. Here is some code which I try to implement:
import uarray as array
data_array = array.array('f',[])
for i in range (counter, counter+N_SAMPLE):
data_array=data_array.append(float(f.readline()))
I have an issue in the last line and the error in REPL is that data_array does not have the attribute append
In the documentation, I see that attribute exists but I am not sure why do I get the error. I tried reading from file separately and that is a correct value. Can anyone give me some help or suggest another alternative I may use?
uarray issues
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: uarray issues
The following works here on a Pyboard:
Code: Select all
>>> from array import array
>>> a = array('f',[])
>>> a.append(1.0)
>>> a.append(1.0)
>>> a
array('f', [1.0, 1.0])
>>>
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: uarray issues
Dear Peter,
Thank you for your quick reply. I modified my code according to your code (which also worked on my pyboard) to:
from array import array
data = array('f',[])
for i in range (counter, counter+N_SAMPLE):
data=data.append(float(f.readline()))
and I still get the AttributeError : NoType object has no attribute append. Unfortunately I cannot see why is that
When I check the counter, N_SAMPLE they are all initialised but the error is still in the last line...
Thank you for your quick reply. I modified my code according to your code (which also worked on my pyboard) to:
from array import array
data = array('f',[])
for i in range (counter, counter+N_SAMPLE):
data=data.append(float(f.readline()))
and I still get the AttributeError : NoType object has no attribute append. Unfortunately I cannot see why is that
When I check the counter, N_SAMPLE they are all initialised but the error is still in the last line...
Re: uarray issues
Dear Peter,
your comment was very useful. I used data_array=data_array.append(float(f.readline())) when I should have used data_array.append(float(f.readline()))
A rookie mistake.
best wishes,
emp20
your comment was very useful. I used data_array=data_array.append(float(f.readline())) when I should have used data_array.append(float(f.readline()))
A rookie mistake.
best wishes,
emp20