On 13 October 2012 17:38, Joshua Landau <span dir="ltr"><<a href="mailto:joshua.landau.ws@gmail.com" target="_blank">joshua.landau.ws@gmail.com</a>></span> wrote:<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote"><div>This here isn't a flaw in Python, though. It's a flaw in the command-line interpreter. By putting it all on one line, you are effectively saying: "group these". Which is the same as an "if True:" block, and some things like Reinteract even supply a grouping block like "build".</div>
<div><br></div><div>That said, because some shells suck it would be nice if:</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<font face="courier new, monospace">python -c "a=1\nif a:print(a)"</font></blockquote><div>worked (just for -c).</div></div><br>
</blockquote></div><br><div>And, spurred on by another thread, this has become possible.</div><div><br></div><div>Make a file like so, install it if you wish.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span style="font-family:'courier new',monospace">import sys<br></span><span style="font-family:'courier new',monospace">evaluable = sys.argv[1].encode("utf8").decode("unicode_escape")<br>
</span><font face="courier new, monospace">exec(evaluable)</font></blockquote><div><br></div><div>This lets you do this:</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<font face="courier new, monospace">python unicode_escape.py "a = [] ##\nfor x in range(100): ##\n a.append(x) ##\n a.append(x**2) ##\nprint(a)"</font></blockquote><div><br></div><div>It's ugly, but it works and only takes one line.</div>
<div><blockquote></blockquote><blockquote></blockquote></div>