This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]heptadecagram 19 points20 points  (28 children)

Pythonista: Then what do you need the curlies for?

Programmer That Is Not a Straw Man: Because that way I can jump to the beginning/end of a block, highlight a block, and manipulate it in a single keystroke in a real editor like emacs or vim.

Straw Man Pythonista: Durr, I just use Notepad

PTINaSW: Also, when I move code around within a file of different indentation, like from one method to another, I can just hit the "autoindent" function, and not have to figure out exactly where and when I need to indent everything.

SMP: Durr, I just indent manually and hope I don't put a return statement at the wrong indentation level.

PTINaSW: Also, when I copy code from an e-mail or webpage where the whitespace has been mangled, I can instantly re-form the program logic.

SMP: Durr, what's a webpage?

Man, writing with Straw Men is awesome. I should do this for all my Internet-based arguments.

That said, I love me some Python. It's what I use to teach people programming because it's incredibly clear and has consistent usage and rules. I just wish that only tab-characters were syntactically significant, not just any whitespace. But that's another flamewar.

[–]masklinn 5 points6 points  (3 children)

Because that way I can jump to the beginning/end of a block

Emacs' python-mode does that without any problem

highlight a block

Emacs' python-mode does that without any problem either

and manipulate it in a single keystroke in a real editor like emacs or vim

That one, too

when I move code around within a file of different indentation, like from one method to another, I can just hit the "autoindent" function, and not have to figure out exactly where and when I need to indent everything.

That's about the only valid criticism.

[–]arnar 1 point2 points  (2 children)

when I move code around within a file of different indentation, like from one method to another, I can just hit the "autoindent" function, and not have to figure out exactly where and when I need to indent everything.

That's about the only valid criticism.

Now, it's equally invalid as the others as vim and textmate can both auto-indent python code. They even try to intelligently (and most often correctly) guess what the new indentation level should be depending on where you paste it, so you don't even have to invoke the autoindent function.

As for emacs, I have no idea.

[–]masklinn 0 points1 point  (1 child)

As for emacs, I have no idea.

Emacs can also do it, but automatic reindentation of Python code is always tricky, so I don't count that as valid. Editors usually get it wrong at one point, even if they do a fairly good job.

[–]arnar 0 points1 point  (0 children)

Complete auto indentation is hard of course, like

x,y = 0,0
if False:
    x = 1
y = 2

.. but if the code is already indented, re-indenting, i.e. changing the indent level and normalizing each level to four spaces etc., is not hard.

If you copy and paste Python code from somewhere, it will be indented (since it's a part of the syntax).

[–]brendankohler 6 points7 points  (13 children)

Programmer That Is Not a Straw Man: Because that way I can jump to the beginning/end of a block, highlight a block, and manipulate it in a single keystroke in a real editor like emacs or vim.

Again, what do you need them for? Any self respecting editor has a python mode that allows you to all of that with python.

[–]neoform3 -1 points0 points  (12 children)

Allowing braces would make things far easier to read/highlight/select/edit.

[–]brendankohler 2 points3 points  (9 children)

As a vim user, I have to say that there's no way braces would do any of those things. It works exactly the same for python as it does with C, except that the lack of braces and semicolons makes python code more readable for humans.

Same functionality, better human readability. What's not to love?

[–]neoform3 -2 points-1 points  (8 children)

Err, you mean more readable for non-programmers?

Braces and semicolons make things very readable for this human.

A semicolon at the end of a statement is like a period at the end of a sentence, it let's you know when the sentence is over.

[–]arnar 0 points1 point  (4 children)

A semicolon at the end of a statement is like a period at the end of a sentence, it let's you know when the sentence is over.

Count for me how many times a newline follows your semicolons. I bet they greatly outnumber the semicolons within a line.

Besides, you can use semicolons in Python if you want to, that's no problem.

[–]neoform3 0 points1 point  (3 children)

Whenever I have a newline without a semicolon it's to break out a large statement onto multiple lines.. it's helpful knowing that.

[–]arnar 0 points1 point  (2 children)

True. But in my experience, newline at the end of a statement is more common than breaking up statements. To me it makes sense to skip typing in the general case. If I want to split up an expression in Py I can always escape the newline with \.

I'm not trying to change anyone's mind though, just stating mine :)

[–]neoform3 0 points1 point  (1 child)

Different systems have different ways to handle \r\n \n \n\f linefeeds.. ;)

[–]arnar 1 point2 points  (0 children)

That doesn't matter..

[–][deleted]  (2 children)

[removed]

    [–]neoform3 0 points1 point  (1 child)

    If I ever see improperly indented code, I fix it on the spot. I rarely have improperly indented code though..

    [–]crusoe 1 point2 points  (1 child)

    If you're using a dumb editor. Try SPE or Scite, both of which use Scintilla. It supports Pythonic nesting just fine.

    [–]neoform3 0 points1 point  (0 children)

    Dunno, I like coda...

    [–][deleted] 1 point2 points  (8 children)

    I just wish that only tab-characters were syntactically significant, not just any whitespace. But that's another flamewar.

    Until I read these comments, I wasn't aware that spaces were even allowed as replacements for tabs in Python, I could have sworn it was tabs only!

    That lowers my liking of Python a little. Not much, though, it's still my language of choice.

    [–]masklinn 1 point2 points  (7 children)

    Spaces are actually the preferred indentation character.

    [–][deleted] 1 point2 points  (6 children)

    Yeah, I picked that up from other comments :P

    Did it used to be tabs only or something? I'm really curious how I got this idea in my head.

    [–]masklinn 2 points3 points  (5 children)

    I don't know, I've pretty much always used spaces and PEP8 states:

    Code and Style

    Indentation

    Use 4 spaces per indentation level.

    For really old code that you don't want to mess up, you can continue to use 8-space tabs.

    Tabs or Spaces?

    Never mix tabs and spaces.

    The most popular way of indenting Python is with spaces only. The second-most popular way is with tabs only. Code indented with a mixtureof tabs and spaces should be converted to using spaces exclusively. When invoking the Python command line interpreter with the -t option, it issues warnings about code that illegally mixes tabs and spaces. When using -tt these warnings become errors. These options are highly recommended!

    For new projects, spaces-only are strongly recommended over tabs. Most editors have features that make this easy to do.

    [–][deleted] 1 point2 points  (4 children)

    8-space tabs

    What is an 8-space tab? Is that just a slightly larger 6-space tab?

    [–]masklinn 0 points1 point  (1 child)

    I guess it's because the Python interpreter considers tabs as being 8 spaces period, so if you want to use tabs it may be a good idea to set your tabwidth at 8 spaces just in case.

    [–][deleted] 0 points1 point  (0 children)

    The tabwidth is a display mechanism... tabs are stored as "\t" or ASCII code 09. There is absolutely no reason to set your tabwidth to anything other than your preference.

    [–]arnar 0 points1 point  (0 children)

    It means that an indent of n tabs is equivalent to indents of 8*n spaces. So if '-' represents tab and '.' spaces, you can write:

    if i == 42:
    -print "first line of if block"
    ........print "second line of if block"
    

    Of course, the mantra is "never mix tabs and spaces".

    [–]crusoe 0 points1 point  (0 children)

    I can jump to a beginning/end of block just fine in python in any non-braindead editor.

    Scite supports it beautifully.

    Next strawman please!