Is it bad to use an IF statement without braces?

Is it bad to use an IF statement without braces?

With the whitespace-based block structure, you don’t have two different methods of creating an if statement: you only have one: While that does have the “issue” that you can’t use the braces at all, you do gain the benefit that it is no more lines that the first style and it has the power to add more statements.

Is it bad practice to use an IF-statement without..?

EDIT: Ned points this out in the comments, but it’s worth linking to here, too, I think. This is not just some ivory-tower hypothetical bullshit: https://www.imperialviolet.org/2014/02/22/applebug.html

Is it bad to omit braces in a block?

With only 50-ish lines per screen height, this is noticeable. There is just one argument against omitting braces: that someone will later add another statement to the block in question and will forget to add the braces, thus inadvertently changing the semantics of the code. This would indeed be a big deal.

Why does rethrow ( E ) violate the principle?

This rethrow (e); function violates the principle which says that under normal circumstances, a function will return, while under exceptional circumstances, a function will throw an exception. This function violates this principle by throwing an exception under normal circumstances. That’s the source of all of the confusion.

What happens when invalid syntax is encountered in Python?

Even if you tried to wrap a try and except block around code with invalid syntax, you’d still see the interpreter raise a SyntaxError. When the interpreter encounters invalid syntax in Python code, it will raise a SyntaxError exception and provide a traceback with some helpful information to help you debug the error.

Is it OK to fix syntax errors on Stack Overflow?

While Stack Overflow is also welcoming rookie coders, it’s mostly targetted at professional programming questions. Answering everyone’s coding mistakes and narrow typos is considered mostly off-topic. So please take the time to follow the basic steps, before posting syntax fixing requests.