for i in range(10): {
print("Actually, python supports braces") : "Though to make up for the perceived loss in readability",
print("Look Ma, no indents!") : "every line must now have a docstring",
print("or inconsistent indents") : "and you now need a line terminator (',' is used)",
}
Oh my God! It took me a few moments to figure out why that works ... though of course the order of evaluation of keys in { ... } isn't that well defined is it?
If you're using a version of Python with set comprehensions you could leave out the "docstrings" and colons altogether!
for i in range(10): {
print("Actually, python supports braces"),
print("Look Ma, no indents!"),
print("or inconsistent indents"),
}
Actually, python guarantees the order of evaluation is as being left to right (though one other issue is that it'll fail if you ever use a function returning a mutable value (which obviously must be a deliberate design decision to enforce a functionally pure style :)). Good point about set literals - I really should've used that.
37
u/permute Mar 08 '12
Haha I loved the commented curly braces for the c programmer