3 ms·
Yeah. Often it's bad style, but IMHO if you just need to do something like: x = 0; y = []; z = None Then it is actually clearer to group them together, it
by gaius 18y ago
Yeah. Often it's bad style, but IMHO if you just need to do something like:
x = 0; y = []; z = None
Then it is actually clearer to group them together, it means more "real code" on screen at a time.
- eru 18y agoI do not know whether that was a good example to show the benefits of the semicolon: x, y, z = 0, [], None
- lehmannro 18y agoWhile the semicolon is only a convenience it has some common use cases. For example shoot-and-forget invokations of third party modules: import sys; sys.exit() import pdb; pdb.set_trace() import cgitb; cgitb.enable() import psyco; psyco.full() import pygtk; pygtk.require('2.0') And of course it's pretty useful in environments where one-liner are easier to handle: $ python -c "import mymod; mymod.test()"
- gaius 18y agoNow that I look in my code I actually have: import matplotlib; matplotlib.use('Agg'); from matplotlib import pyplot
- ulf 18y agoIn this case you could just use: x, y, z = 0, [], None