Basically, this works in Matlab because spaces are used to separate items in a sequence, and Matlab will let you use newlines instead of spaces. In other words, you can do x = [1 2 3]
In python, commas are used instead. In other words, you need to do x = [1, 2, 3].
Python will let you have newlines in an expression if you've opened a brace/bracket, etc. For example, you can do:
In [1]: x = [1,
...: 2,
...: 3,
...: 4]
In [2]: x
Out[2]: [1, 2, 3, 4]
...but you still need the commas for it to be valid syntax.
If you want to use newlines as a seperator for the sequence (that you've presumably copied to the clipboard), you'll need to explicitly split the string on newlines.
To start a multi-line string, use triple-quotes. (""" or ''')
For example: (I've typed x = """ and then hit paste (e.g. <ctrl>-v/<shift>-<ins>/whatever))
In [1]: x = """4
...: 1
...: 5
...: 2
...: 15
...: 1"""
In [2]: x
Out[2]: '4\n1\n5\n2\n15\n1'
In [3]: x.split()
Out[3]: ['4', '1', '5', '2', '15', '1']
In [4]: import numpy as np
In [5]: np.array(x.split(), dtype=float)
Out[5]: array([ 4., 1., 5., 2., 15., 1.])
Also, as @HYRY mentioned, if you're using ipython, it will do the equivalent of
In [1]: x = """4
...: 1
...: 5
...: 2
...: 15
...: 1"""
In [2]: x = x.split()
With just:
In [1]: %paste x
Better yet, if you're reading data in from the serial port, just read it directly into python. Have a look at pyserial: http://pyserial.sourceforge.net/
a = PASTE?a = [then paste then type]and then press enter? So I'm sure you can do that in Python too? What Python IDE are you using?