List Comprehension Syntax
Ville Vainio
ville at spammers.com
Mon Jul 12 16:05:34 EDT 2004
>>>>> "Peter" == Peter Hansen <peter at engcorp.com> writes:
Peter> Not sure what you mean here. The indentation approach I'm
Peter> referring to (i.e. the "standard" way, as opposed to what I
Peter> was calling the "artistic" way) is just to hit tab in
Peter> precisely the same way you would if you were indenting an
Peter> "if" block.
In emacs, tab is 'indent-line', which gives the line "correct"
indentation. Occasionally one needs to dedent a line manually to close
a block. Pressing <enter> puts the cursor in the right place
immediately (indenting on ':', dedenting on 'return').
if 1:
hui();
If I press tab on line with hui(), the result is
if 1:
hui();
>> Anyway, the point is mostly moot because
>> blah = [
>> i + 1
>> for i in range(10)
>> if i != 3
>> ]
>> indents the way you want it to, and that's the way I usually do it
>> anyway. I just M-x indent-region'ed your code snippet :).
Peter> Not sure which code-snippet you refer to, but the ones that
Peter> I typed were indented the same way, except perhaps that I
Peter> put the first expression the same line as the opening
Peter> bracket.
Yes, and that made the difference.
--
Ville Vainio http://tinyurl.com/2prnb
More information about the Python-list
mailing list