If you come from a Visual IB psic background, Python's style of line continuation should be familiar. The only real difference between the two is Python's use of a backslash (\) and Visual Basic's use of an underscore(_) and an End •latement (Function End,Sub End, etc.) to mark the end of a statement instead of indentation.

If you come from a Java background, Python's line continuation and code block in dentation may seem a little weird. Java explicitly ends statements with a semicolon, so there's no need for a line continuation indicatoo tt uses the backslash for ntting continuftion. Indenting in Java is strictly up to the taste and style of the individual programmer.

Statements use whitespace—tabs and spaces—to denote an associated block of code. It can also denote a suite associated with a clause in a compound statement . (Gompound statements and suites will be covered in Chapter 3.) The amount of whitespace within a statement doesn't matter. All of the following examples do the same thing even though the whitespace in each is different.

Was this article helpful?

0 0

Post a comment