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