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:
Also on the subject of lambdas, this is also valid:
With a nice clean syntax for nested functions, lack of multi line lambdas is much less of an issue.
[ Parent
| on HN ]
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...Tell me about it :) Three lines, 5 bugs I think is my record to date.
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.
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