You're looking at Less Wrong's discussion board. This includes all posts, including those that haven't been promoted to the front page yet. For more information, see About Less Wrong.

Viliam_Bur comments on More intuitive programming languages - Less Wrong Discussion

4 Post author: A4FB53AC 15 April 2012 11:35AM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (89)

You are viewing a single comment's thread. Show more comments above.

Comment author: Viliam_Bur 18 April 2012 11:52:47AM 1 point [-]

In Python, you are supposed to write a colon before you start a block, right?

So the rules can be rather simple:

  • colon, with indentation = start of a new block

  • colon, no indentation = an empty block (or a syntax error)

  • no colon, with indentation = continuing of the previous line

  • no colon, no indentation = next statement

  • semicolon = statement boundary

Block ends where the indentation returns to the level of the line that opened the block. Continued line ends when indentation returns to the level of the starting line. (Where "to the level" = to the level, or below the level.)