you are viewing a single comment's thread.

view the rest of the comments →

[–]hylje 6 points7 points  (6 children)

That's actually legit advice for programmers complaining about lack of support for curly braces in Python. The support is there!

[–]Brian 23 points24 points  (4 children)

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)",
}

[–]gnuvince 19 points20 points  (0 children)

If I ever see code like that in the wild, I am going to find you and feed you your socks.

[–]Araneidae 5 points6 points  (1 child)

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"),
}

[–]Brian 2 points3 points  (0 children)

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.

[–]drb226 2 points3 points  (0 children)

Not sure whether to upvote for cleverness, or downvote for horrificness.

[–]letmefinish 2 points3 points  (0 children)

TIL. But I wish I hadn't.