4 ms·
> how about an almost Erlang-like full stop? This is just brackets/braces in disguise, at which point you might as well follow convention and use {}. This is
by guitarbill 10y ago
> how about an almost Erlang-like full stop?
This is just brackets/braces in disguise, at which point you might as well follow convention and use {}.
This is obviously a very personal issue, but for me, the whitespace has less cognitive load. E.g.: in languages with brackets, people usually still indent the code for readability.
I've also found that when teaching people to program, consistency works well. I think this is one of the reasons Python is easy to pick up, just because Python code consistently looks like Python.
- pmontra 10y agoFor those languages is not people who reindent code but it's the editor or the IDE. There is usually a key to force reindentation. That is possible because {} or even the end in Ruby are easy markers for the block (there are multiple markers for a block start in Ruby). Is there any automatical indentation function in some editor for Python? If not, it's Python the unfortunate language where people has to indent code to feed the compiler. I always hated doing the compiler's job. I'm asking because I'm using Python little and only for short scripts, so I didn't bother investigating much. Still I've been bitten a couple of times by bugs introduced by moving code around and not noticing that a line was not indented correctly. That in Python and in Haml (http://haml.info/ http://haml.info/) If somebody knows about those tools I will appreciate and it will make my life easier. BTW, I'm fixing somebody's else Python scripts right now :-)
- squeaky-clean 10y ago> For those languages is not people who reindent code but it's the editor or the IDE. There is usually a key to force reindentation. Regardless of whom or what is doing the indentation, people still prefer reading code which is indented, even in a language which relies on braces or parenthesis for flow. The indenting is not for the compiler's sake, it has no problem understanding this: http://www.ioccc.org/2014/maffiodo1/prog.c http://www.ioccc.org/2014/maffiodo1/prog.c Also people get very picky and personal when it comes to indentation in ways that a computer can't always choose. I prefer to almost always indent and format my code myself, rather than letting the editor choose. Python is the only language I actually let my editor auto-format, because of PEP-8. > Is there any automatical indentation function in some editor for Python? Pretty much any editor will have a feature for this, or allow you to install a popular plugin for it in less than a minute.
- pmontra 10y agoHow does it know that a line pasted to the end of a block from another indentation level belongs to that block or should go after the end of the block? if cond: line pasted line # where does it go?