News for hackers. Stuff that matters.
Re:Python best practices by DocSavage on Tuesday July 08, 2008 @08:32PM (#240576)
> Extraneous spaces annoy me to end.

It is recommended in the "official" python style guide to surround the assignment operator with a single space: http://www.python.org/dev/peps/pep-0008/

Re:Python best practices by attack on Tuesday July 08, 2008 @08:59PM (#240596)
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.
Re:Python best practices by BrandonM on Tuesday July 08, 2008 @10:04PM (#240644)
I 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.
Re:Python best practices by BrandonM on Wednesday July 09, 2008 @03:15AM (#240883)
The 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]
Re:Python best practices by albertcardona on Wednesday July 09, 2008 @12:16PM (#241312)
Same 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.
Re:Python best practices by bkovitz on Wednesday July 09, 2008 @03:15PM (#241543)
Same here, for the same reason.
Re:Python best practices by bkovitz on Wednesday July 09, 2008 @11:46AM (#241276)
I do. I find that code with the spaces around assignment and arithmetic operators is way easier to read.
Re:Python best practices by thorax on Wednesday July 09, 2008 @02:04AM (#240839)
I do all of these (even in interactive shell) except I have a weak spot for this sort of notation:

    i+=2