<br><br><div class="gmail_quote">On Thu, May 3, 2012 at 12:21 PM, Garrett Cooper <span dir="ltr"><<a href="mailto:yanegomi@gmail.com" target="_blank">yanegomi@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 class="HOEnZb"><div class="h5">On Thu, May 3, 2012 at 12:03 PM, Ian Kelly <<a href="mailto:ian.g.kelly@gmail.com">ian.g.kelly@gmail.com</a>> wrote:<br>
> On Thu, May 3, 2012 at 12:49 PM, Garrett Cooper <<a href="mailto:yanegomi@gmail.com">yanegomi@gmail.com</a>> wrote:<br>
>>    I was wondering whether this was a parser bug or feature (seems<br>
>> like a bug, in particular because it implicitly encourages bad syntax,<br>
>> but I could be wrong). The grammar notes (for 2.7 at least [1]) don't<br>
>> seem to explicitly require a space between 'in' and another parser<br>
>> token (reserved work, expression, operand, etc), but I could be<br>
>> misreading the documentation.<br>
><br>
> The grammar doesn't require whitespace there.  It tends to be flexible<br>
> about whitespace wherever it's not necessary to resolve ambiguity.<br>
><br>
>>>> x = [3, 2, 1]<br>
>>>> x [0]if x [1]else x [2]<br>
> 3<br>
>>>> 1 . real<br>
> 1<br>
>>>> 1.5.real<br>
> 1.5<br>
<br>
</div></div>    Sure.. it's just somewhat inconsistent with other expectations in<br>
other languages, and seems somewhat unpythonic.<br>
    Not really a big deal (if it was I would have filed a bug<br>
instead), but this was definitely a bit confusing when I ran it<br>
through the interpreter a couple of times...<br>
Thanks!<br>
<span class="HOEnZb"><font color="#888888">-Garrett<br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br>For the code prettiness police, check out pep8 and/or pylint.  I highly value pylint for projects more than a couple hundred lines.<br><br>For the whitespace matter that's been beaten to death:<br>
<a href="http://stromberg.dnsalias.org/~strombrg/significant-whitespace.html">http://stromberg.dnsalias.org/~strombrg/significant-whitespace.html</a><br><br>I'll include one issue about whitespace here.  In FORTRAN 77, the following two statements look very similar, but have completely different meanings, because FORTRAN had too little significant whitespace:<br>
<br>DO10I=1,10<br>DO10I=1.10<br><br>The first is the start of a loop, the second is an assignment statement.<br><br>