News for hackers. Stuff that matters.
Re:Python-Dev: Adding braces to __future__ by pnathan on Monday January 02, 2012 @10:59AM (#3416260)
Whitespace blocks means my editor can not correctly reindent when I shift levels of indentation and instruct the editor to pretty-reformat. This wastes my time because I have to manually sort things out. It also means that things I can't see are affecting my code. It's a pain to work with in Python and a pain to work with in Haskell. My experience is that it's an epically bad idea made attractive by revulsion from C++/Java.

Curlies or Lisp-like curves play a ton nicer with tooling and visual inspection.

Re:Python-Dev: Adding braces to __future__ by Pewpewarrows on Monday January 02, 2012 @11:17AM (#3416323)
As a Vim / ST2 user I've never once had to fight with indentation levels. The only time I ever have to even think about them are when cut/copy/pasting code around. And even then it's just a quick re-highlight and spam the indent key one way or the other.
Re:Python-Dev: Adding braces to __future__ by mattdeboard on Monday January 02, 2012 @11:04AM (#3416275)
Sounds like a problem with your choice of editor, not Python. Try emacs or vim.
Re:Python-Dev: Adding braces to __future__ by pnathan on Monday January 02, 2012 @11:06AM (#3416279)
I use emacs.

It's an ambiguity problem similar to the dangling else. There's no way to automatically tell the editor that I want the statements to go here or there.

edit: Yes, there's a reformat command in emacs. No, it does not work correctly for Python, because the lack of delimiters means it does not have the information it needs to do the job right.

Re:Python-Dev: Adding braces to __future__ by exDM69 on Monday January 02, 2012 @11:19AM (#3416330)
Do you have the appropriate emacs plugins for writing Python? I'm a bit surprised that the code isn't formatted properly with emacs out of the box. Then again, many editors need some sort of addon to be able to cope with whitespace sensitive syntax.

If it were an actual grammatical ambiguity, any editor couldn't get it right but it can't be since the Python parser can understand it.

Re:Python-Dev: Adding braces to __future__ by pnathan on Monday January 02, 2012 @11:26AM (#3416352)
It is not a grammatical ambiguity in terms of Python.

Here's a pastebin that illuminates the problem.

http://pastebin.com/3fdxts4n

Re:Python-Dev: Adding braces to __future__ by mattdeboard on Monday January 02, 2012 @12:00PM (#3416474)
I see. I never have that problem because when I C-S-<Backspace> and put my cursor at the beginning of the line I want to paste it retains indentation level fine.

edit: What version of emacs are you using? Are you using python.el or python-mode.el for editing Python? python.el handles try/except, if/else, etc., etc., indentation pretty marvelously.

edit2: If you'd rather talk about this out-of-band I'm on freenode as mdeboard or my email address is in my profile.

Re:Python-Dev: Adding braces to __future__ by pnathan on Monday January 02, 2012 @12:25PM (#3416575)
23.3.x and python.el. It's very stock. What function does C-S-backspace give you? I see kill-whole-line on my install. Once I am writing in a block, the indents work fine, but... I can't paste something into a block and whack the 'reformat all' to come out correctly, especially if it has multiple levels of indentation. Since my code gets reworked substantially while I'm in the middle of it, this wastes my time. Braces are not noise...
Re:Python-Dev: Adding braces to __future__ by mattdeboard on Monday January 02, 2012 @12:39PM (#3416631)
It sounds like you need to use the kill ring & pasting from the kill ring more. It preserves indentation levels, and selecting a region then M-x indent-region will handle all this for you.
Re:Python-Dev: Adding braces to __future__ by rmc on Monday January 02, 2012 @11:10AM (#3416302)
In Vim, just select the text (with V), then use < or > to deinter or indent resp.
Re:Python-Dev: Adding braces to __future__ by decklin on Monday January 02, 2012 @11:14AM (#3416314)
That's what he meant by "manually".
Re:Python-Dev: Adding braces to __future__ by Dobbs on Monday January 02, 2012 @11:09AM (#3416294)
Vim has this problem also.
Re:Python-Dev: Adding braces to __future__ by obtu on Monday January 02, 2012 @11:29AM (#3416363)
vim has a :set paste toggle for its input mode.
Re:Python-Dev: Adding braces to __future__ by silon4 on Monday January 02, 2012 @11:34AM (#3416380)
Agreed, but there's a solution. Emacs recognises the end of a block by using "pass" to end the block. This makes it reindent properly. It's not the official python style, but I prefer to write code that way. Try it, it's not bad.
Re:Python-Dev: Adding braces to __future__ by BerislavLopac on Monday January 02, 2012 @11:59AM (#3416469)
The obligatory XKCD quote: "These are your father's parentheses." http://xkcd.com/297/ ;)
Re:Python-Dev: Adding braces to __future__ by nailer on Monday January 02, 2012 @11:22AM (#3416344)
Can you not see where the first character on a line is?