5 ms·
And look how complicated they make it. Sometimes spaces, sometimes not, how confusing. And tell me that their "Use spaces around arithmetic operators" example d
by attack 18y ago
And look how complicated they make it. Sometimes spaces, sometimes not, how confusing. And tell me that their "Use spaces around arithmetic operators" example doesn't make you want to puke:
i = i + 1
submitted += 1
x = x * 2 - 1
hypot2 = x * x + y * y
c = (a + b) * (a - b)
Who writes like that?? I very strongly disagree.
- BrandonM 18y agoI do. I think it looks a lot better and more clear. It certainly looks a lot like what I would write down on paper, and that is one of the inherent qualities of Python in general.
- BrandonM 18y agoThe one place that I don't follow the guideline (unless it's the guideline and I just don't know it... it rarely comes up, so I haven't bothered to check) is on array indices. I do write: a[i+1]
- albertcardona 18y agoSame here. I conceptualize it as part of a code compactness strategy: array indices are part of the same item, and thus I use syntax (like yours) that suggests inlining.
- bkovitz 18y agoSame here, for the same reason.
- joeread 18y agoYou write with big gaps like that? No you don't...
- sah 18y ago"Who writes like that??" The authors of: BitTorrent: https://develop.participatoryculture.org/trac/democracy/browser/trunk/tv/portable/BitTorrent/Choker.py?rev=4 https://develop.participatoryculture.org/trac/democracy/brow... Django: http://code.djangoproject.com/browser/django/trunk/django/utils/dateformat.py http://code.djangoproject.com/browser/django/trunk/django/ut... Pylons: http://pylonshq.com/project/pylonshq/browser/pylons/util.py http://pylonshq.com/project/pylonshq/browser/pylons/util.py Twisted: http://twistedmatrix.com/trac/browser/trunk/twisted/python/util.py http://twistedmatrix.com/trac/browser/trunk/twisted/python/u...
- joeread 18y agoNot one of those has more than a couple mathematical operators per line. Very misleading examples. Try again.
- thorax 18y agoI do all of these (even in interactive shell) except I have a weak spot for this sort of notation: i+=2
- joeread 18y agoWhy do you waste time with doubling the number of characters you have to type at the interactive shell?
- bkovitz 18y agoI do. I find that code with the spaces around assignment and arithmetic operators is way easier to read.