3 ms·
You are being kind or your coworker isn't that bad - in your example the whitespace is consistent. My experience is that the whitespace is totally arbitrary: t
by gvb 13y ago
You are being kind or your coworker isn't that bad - in your example the whitespace is consistent. My experience is that the whitespace is totally arbitrary: totally inconsistently placed 0 - n spaces with random indentation levels.
Sloppily formatted code is Edward Bear code. All the bumping makes it hard to think about how it works (or, more often, why it doesn't work).
"Here is Edward Bear, coming downstairs now, bump, bump, bump, on the back of his head, behind Christopher Robin. It is, as far as he knows, the only way of coming downstairs, but sometimes he feels that there really is another way, if only he could stop bumping for a moment and think of it." - http://www.gurteen.com/gurteen/gurteen.nsf/id/L001362/ http://www.gurteen.com/gurteen/gurteen.nsf/id/L001362/
- pyre 13y ago> My experience is that the whitespace is totally arbitrary: totally inconsistently placed 0 - n spaces with random indentation levels. This is usually due to: 1) Lack of a consistent style guide. 2) Lack of style guide enforcement. 3) A language where white space doesn't matter. If you think about this critically though, these random indentation changes would either break all of the code (e.g. it wouldn't run, or would run but not work correctly) or it would make code maintenance a nightmare. Yet there are plenty of Python shops out there, and we don't hear horror stories of Python white space maintenance nightmares. Either the Python community is doing a good job of hiding these issues, or they really aren't issues in practice. Of the people I've talked to in-person about Python semantic white-space, the common threads are either: 1) It's different than what I'm used to. 2) It's cramping my style. My code is art, and restricting how I can structure my code is an affront to my very being.
- jessaustin 13y agoI guess I'm in a third camp: 3) Python's semantic whitespace is so wonderful I'm baffled that most other programming languages don't have it. It's like they're coding with one eye shut: why not do this wonderful thing that makes everything easier?
- pyre 13y agoI meant to say of the people that were upset by Python's semantic whitespace, those were the two general reasons why.
- Goladus 13y ago2) It's cramping my style. My code is art, and restricting how I can structure my code is an affront to my very being. To be fair, there are quite a few common cases where Python's syntax is rather inelegant. The need to break out if-then statements into multiple lines, the need for explicit 'return' statements which also have to go on their own line. These things are only indirectly related to whitespace but do sometimes put a lower bound on expressiveness.
- pyre 13y ago> To be fair, there are quite a few common cases where Python's syntax is rather inelegant Now we're stepping out of the realm of "semantic white space" though. The people I've known to get (literally) red in the face over Python haven't actually used the language and can't do much more than regurgitate stuff like, "but white space!" > The need to break out if-then statements into multiple lines, the need for explicit 'return' statements which also have to go on their own line. Unless I'm missing something those are poor examples of the limits of semantic white space: % python >>> def function(): ... if True: return False ... >>> function() False >>> def function(): ... if False: return True ... else: return False ... >>> function() False Sure you can't do stuff like: >>> def function(): ... True ... >>> function() >>> (That returned `None`) But I don't see how requiring a return statement, or disallowing code like: if var1 = function(): do_something() is a crime against humanity.
- Goladus 13y agoActually after a quick search I realized my problem was ignorance. I did not know about PEP 308 (conditional expressions) which is a workaround for the issue I described. And yes technically it's a statement/expression issue not a whitespace issue, though they're indirectly related.