To read all comments associated with this story, please click here.
I thought that would bug me when I first started using Python back in the 1.x days, and it did. However, it really stops being an issue after just a short while.
While I'm a die-hard fan of parenthesis and curly braces, I think Python's syntax forces good code formatting and makes your code very easy to read. Also, when a problem comes my way, the first language I reach for to solve it is Python, so I think the Python team must be doing something right; at least from my point of view.
Seconded. Plus, there's a tool for those who want to program in python and still use curly brackets, IIRC.
The main difficulties caused by the significant indentation thing are:
a) Immediate yuck-reaction from former C programmers and those scarred by non-free-form FORTRAN.
b) Copying and pasting from forums gets harder. Whether or not this is bad is up to debate.
c) Mixing of tabs and spaces, especially in projects with more than one developer. If you can't get a bunch of people to follow the same coding style OR use a tool that changes the code accordingly, Python is probably the least of your problems, as in case b).
I've only used Python recently because it's just so much easier to remember/relearn than e.g. C++, especially if you just program in your spare time, for fun.
Except that if you want to keep your code width limited to, say, 80 columns, then in many cases you are forced to use backslashes at the end of a line to inform python that you intend to continue it in the next. I personally prefer braces or "end" keywords over having to do this manual dance, which sometimes makes me feel I'm writing for the C preprocessor.
Example:
$ cd /usr/share/blender/scripts && grep '\\$' *.py | wc -l
938
Edited 2008-10-10 09:02 UTC
I've programmed a decent amount of python and I still agree. I do appreciate that it forces sane indentation and so helps readability, but the problem is that you get a source of bugs that is just about invisible. By missing an indent (space), you can end up with an if statement where the last statement you believe to be in scope is actually outside, and thus executed regardless of the if condition. This does not actually happen often. But when it does, it's a bitch to find.
My point? Syntax elements should be visible. Other than that, love python.
Well, this is everybody's big pet peeve with Python. The first time I thought about switching from Perl to Python, I saw the whitespace thing and decided to ignore it for the next 3 years. Boy, big mistake. Now that I use Python for practically everything and love it to death, I don't notice the whitespace issues one bit.
I sometimes think Guido (Python's creator) takes a perverse delight in turning away all of us shallow-minded programmers. He thinks to himself, "Oh gosh, there goes another fool passing up the greatest programming language ever, with no idea of what he/she is missing." Well, I'm proud to have become a true believer
I totally agree with you. I used Perl for about seven years, pretty heavily, before getting into Python.
I tried to learn Python a couple of times, but like others have said, the whitespace thing through me off totally. In mid-2005, I took a contract with IBM, and the group I worked with was heavily into Python, so I bought "Learning Python" and the rest is history. Like parent said, I do not even notice the whitespace thing any longer, and find the readability of Python to be head and shoulders above Perl (and most other languages as well).
Advice to those who still scoff at Python because of enforced whitespace rules: Just try it. Grab a copy of "A Byte of Python" or perhaps "Dive into Python" and just do it, you really won't be sorry.
I don't know man. I mean, I think Python's string formatting features are pretty bad. Look at the way Groovy handles strings and interpolation... so much more elegant.
In fact, look at the way Groovy does closures. It's actually unbelievable how much you can accomplish in Groovy in just a few lines of code... and it is readable too.
Now, I'm not saying Groovy is the best programming language ever, but I'm just making a point.
I liked that in the beginning, actually, since I'm formatting and indenting my code anyway, and I liked it to be forced to do that.
But now, I also see the disadvantages: Whenever you copy & paste code, or you move some code block to somewhere else, it's just not as convenient, because you always have to look that you're doing it correctly, even if you're just testing something quickly.
And also, it's a problem when you want to comment out an if- or while-line so that the condition is gone and the code is definitely executed. Because if you do that, you have to de-indent the code block, and things might get very messy that way.
So those are the drawbacks for me, but of course it's also got some nice advantages.
No, just replace the condition to True and you're done.
That seems to be everybody's pet peeve... everybody that hasn't programmed more than an hello world in Python, that is...
I've been there, so I'm speaking from experience. But once you start using Python instead of just reading about it, you realise that the whitespace rules are mostly invisible... I don't remember the last time I had some problem related to whitespace indentation. Actually, I don't remember _ever_ having such a problem...
But you end up noticing something... in other languages. I now find myself looking at C, java, etc. and thinking that they look messy (the same thing I always thought about perl). The absense of most delimiters in Python makes code look clean and concise (and easier to read).







Member since:
2005-09-20
My biggest peeve with python is the use of spaces to delimit blocks of statements. Does somebody have something against punctuation or what?