<div dir="ltr"><div><div>I'd just do this, which works today:<br><br>==================<br>import numpy<br>import io<br><br>ar = numpy.loadtxt(io.StringIO("""<br>1 5 9 155<br>53 44 44 34<br>"""))<br>==================<br></div><br></div><div>Of course, this is only worth the trouble if you<br></div><div>are somehow loading a very large matrix.<br></div><div>(And then, are you sure you want to embed it in your code?)<br></div><div><br></div>Stephan<br><div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-03-15 6:15 GMT+01:00 Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thu, Mar 15, 2018 at 01:32:35AM +0100, Mikhail V wrote:<br>
<br>
> Idea is a concept for 2D arrays/lists syntax, which should simplify<br>
> some editing boilerplate while working with arrays and improve<br>
> readability for bigger arrays.<br>
<br>
</span>I don't understand; we already have perfectly good syntax for working<br>
with 2D arrays.<br>
<span class=""><br>
> Lets start with a simple list example :<br>
><br>
> L ===<br>
> 1 5 9 155<br>
> 53 44 44 34<br>
><br>
> returns a 2d list:<br>
> [[1, 5, 9, 155], [53, 44, 44, 34]]<br>
<br>
</span>We already have:<br>
<br>
L = [[1, 5, 9, 155], [53, 44, 44, 34]]<br>
<br>
which is more compact (one line rather than two) and explicitly delimits<br>
the start and end of each list. Like everything else in Python, it uses<br>
commas to separate items, not whitespace. If you prefer:<br>
<br>
L = [[1, 5, 9, 155],<br>
[53, 44, 44, 34]]<br>
<br>
<br>
Using spaces to separate items has the fatal flaw that it cannot<br>
distinguish<br>
<br>
x - y 0 # two items, the expression `x - y` and the integer 0<br>
<br>
from:<br>
<br>
x - y 0 # three items, `x`, `-y`, and 0<br>
<br>
<br>
making it ambiguous. I stopped reading your post once I realised that.<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
Steve<br>
</font></span><div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br>
</div></div></blockquote></div><br></div></div>