Quantcast
Channel: Why is semicolon allowed in this Python snippet? - Stack Overflow
Browsing latest articles
Browse All 16 View Live

Answer by Mohd Asim for Why is semicolon allowed in this Python snippet?

Semicolon (";") is only needed for separation of statements within a same block, such asif we have the following C code:if(a>b){ largest = a; // Here 'largest' and 'count' are integer variables...

View Article



Answer by Farhan Hai Khan for Why is semicolon allowed in this Python snippet?

Related to the Matplotlib library:import numpy as npimport matplotlib as plt%matplotlib notebooklinear_data = np.array([1, 2, 3, 4, 5, 6, 7, 8])quadratic_data = linear_data**2plt.figure()xvals =...

View Article

Answer by Konstantin Burlachenko for Why is semicolon allowed in this Python...

It's allowed because authors decided to allow it:6. Simple statementsIf moving to the question why authors decided to do so, I guess it's so because semicolon is allowed as a simple statement...

View Article

Answer by eSurfsnake for Why is semicolon allowed in this Python snippet?

I realize I am biased as an old C programmer, but there are times when the various Python conventions make things hard to follow. I find the indent convention a bit of an annoyance at times.Sometimes,...

View Article

Answer by gboffi for Why is semicolon allowed in this Python snippet?

Semicolon in the interpreterHaving read the answers, I still miss one important aspect of using semicolons, possibly the only one where it really makes a difference...When you're working in an...

View Article


Answer by Raymond for Why is semicolon allowed in this Python snippet?

Semicolons (like dots, commas and parentheses) tend to cause religious wars. Still, they (or some similar symbol) are useful in any programming language for various reasons.Practical: the ability to...

View Article

Answer by kindall for Why is semicolon allowed in this Python snippet?

Python uses the ; as a separator, not a terminator. You can also use them at the end of a line, which makes them look like a statement terminator, but this is legal only because blank statements are...

View Article

Answer by Ben for Why is semicolon allowed in this Python snippet?

As everyone else has noted, you can use semicolons to separate statements. You don't have to, and it's not the usual style.As for why this is useful, some people like to put two or more really trivial...

View Article


Answer by mandarg for Why is semicolon allowed in this Python snippet?

Multiple statements on one line may include semicolons as separators. For example: 8. Compound statements. In your case, it makes for an easy insertion of a point to break into the debugger.Also, as...

View Article


Answer by craniumonempty for Why is semicolon allowed in this Python snippet?

Semicolons can be used to one line two or more commands. They don't have to be used, but they aren't restricted.The semicolon ( ; ) allows multiple statements on the single line given that neither...

View Article

Answer by chown for Why is semicolon allowed in this Python snippet?

From 8. Compound statements:Compound statements consist of one or more ‘clauses.’ A clauseconsists of a header and a ‘suite.’ The clause headers of a particularcompound statement are all at the same...

View Article

Answer by CommunistPancake for Why is semicolon allowed in this Python snippet?

A quote from "When Pythons Attack"Don't terminate all of your statements with a semicolon. It's technically legal to do this in Python, but is totally useless unless you're placing more than one...

View Article

Answer by Godwin for Why is semicolon allowed in this Python snippet?

Python does let you use a semicolon to denote the end of a statement if you are including more than one statement on a line.

View Article


Answer by André Caron for Why is semicolon allowed in this Python snippet?

Python does not require semicolons to terminate statements. Semicolons can be used to delimit statements if you wish to put multiple statements on the same line.Now, why is this allowed? It's a simple...

View Article

Answer by Dmitry B. for Why is semicolon allowed in this Python snippet?

Semicolons are part of valid syntax: 8. Compound statements (The Python Language Reference)

View Article


Why is semicolon allowed in this Python snippet?

Python does not warrant the use of semicolons to end statements.So why is this (below) allowed?import pdb; pdb.set_trace()

View Article
Browsing latest articles
Browse All 16 View Live




Latest Images