<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Oct 19, 2016 at 3:55 PM, Joseph Jevnik <span dir="ltr"><<a href="mailto:joejev@gmail.com" target="_blank">joejev@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>You could add or prototype this with quasiquotes (<a href="http://quasiquotes.readthedocs.io/en/latest/" target="_blank">http://quasiquotes.<wbr>readthedocs.io/en/latest/</a>). You just need to be able to parse the body of your expression as a string into an array. Here is a quick example with a parser that only accepts 2d arrays:<br><br>```<br># coding: quasiquotes<br><br>import numpy as np<br>from quasiquotes import QuasiQuoter<br><br><br>@object.__new__<br>class array(QuasiQuoter):<br>    def quote_expr(self, expr, frame, col_offset):<br>        return np.array([<br>            eval('[%s]' % d, frame.f_globals, frame.f_locals)<br>            for d in expr.split('||')<br>        ])<br><br><br>def f():<br>    a = 1<br>    b = 2<br>    c = 3<br>    return [$array| a, b, c || 4, 5, 6 |]<br><br><br>if __name__ == '__main__':<br>    print(f())<br>```<br></div></div></blockquote><div><br></div><div>Interesting project, thanks!  If there is any actual interest in this that might be a good way to prototype it.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div></div>Personally I am not sold on replacing `[` and `]` with `|` because I like that you can visually see where dimensions are closed.<br></div><div class="gmail_extra"><br></div></blockquote><div><br></div>Yes, that issue occurred to me.  But assuming a rectangular matrix, I had trouble coming up with a good example that is clearer than what you could do with this syntax.  For simple arrays it isn't needed, and complicated arrays are large so picking out the "[" and "]" becomes visually harder at least for me.  Do you have a specific example that you think would be clearer than what is possible with this syntax?  <br><br>Of course that is more of an issue with jagged arrays, but numpy doesn't support those and I am not aware of any plans to add them (dynd is another story).<br></div><div class="gmail_quote"><br>Also keep in mind that this would supplement the existing approach, it doesn't replace it.  np.ndarray() would stay around just like list() stays around for cases where it makes sense.<br></div><br></div></div>