News for hackers. Stuff that matters.
Re:Python vs Clojure by gaius on Wednesday October 14, 2009 @01:15PM (#881696)
Not only that, he's wrong - Python is sensitive to indentation, not whitespace. As long as your block is at the right depth, you can have as much whitespace as you want. I regularly format code so similar things line up. This is perfectly valid Python:

    def foo():
        longvariable = 1
        x            = 2

Also on the subject of lambdas, this is also valid:

    def foo():
       def bar(x):
           return x + 5

        print bar(5)

With a nice clean syntax for nested functions, lack of multi line lambdas is much less of an issue.
Re:Python vs Clojure by JshWright on Wednesday October 14, 2009 @01:43PM (#881766)
To give an example in reply to the Clojure snippet that is now mysteriously missing from the article (to demonstrate something Python users should be jealous of)...

This is perfectly valid in Python:

  users = [ # Name    ID  Age  Phone
             ['John', 5,  37,  '555-1234'],
             ['Bill', 5,  29,  '555-4321'],
             ['Jean', 5,  32,  '555-4132'],
          ]
Edit: Always a good idea to test even the simplest snippets before posting them...
Re:Python vs Clojure by jacquesm on Wednesday October 14, 2009 @03:09PM (#881930)
Tell me about it :) Three lines, 5 bugs I think is my record to date.
Re:Python vs Clojure by jacquesm on Wednesday October 14, 2009 @01:37PM (#881756)
Interesting how your variable example is pretty much straight against the python styleguide:

http://www.python.org/dev/peps/pep-0008/

I'd do it just like you do though.

I find it visually harder to fish those equals signs out of the 'noise' otherwise.

Re:Python vs Clojure by gaius on Thursday October 15, 2009 @10:52AM (#883477)
In the wild, you're more likely to find Python that looks like:

    longvariable, x = 1, 2
However this won't work:

    longvariable, x = 1, foo(longvariable)
So I like to keep things uniform regardless of the rvalue. Also violating the style guide, I like

    longvariable = "hello" # some description of longvariable
    x            = 1       # some descrption of x
Re:Python vs Clojure by yannis on Wednesday October 14, 2009 @01:24PM (#881722)
This reminds me of my high school algebra teacher. He would automatically fail you in tests if your equals did not line up.

Very neat syntax!