Hacker News new | comments | show | ask | jobs | submit login

When programmers discuss Python on the web, this comes up again and again. I agree with you - it is a minus for me in terms of using Python. There are "solutions", there are people who say you get used to it, there are people who say it does not matter, yet it comes up again and again. I guess it does matter, to some of us at least.

I can open up a text editor and start writing C, or Java, or Perl, or PHP - all without that much thought on whitespace, indentation etc. I can later run indent -kr, or perltidy, or astyle and so forth and make the code I banged out look nice and tidy. Sometimes I feel like doing the nice indentation myself while coding, sometimes I do not and let the scripts do it. With Python "there is one way to do it" and you have to think about indentation while coding. It is annoying. It is like Java and exceptions, forcing me to put try/catch loops everywhere and messing up my scope - even for a little prototype program which will be run once and will never need to catch an exception. It is treating me like I am an idiot and forcing me to work in a regimented manner.

When I first learned Python, at one point I decided to put a do/while loop in my program. I was not able to discover how this was done in documentation. I go on IRC #python and am told Python has no do-while loops (which I later confirmed is true). I was told, and I am assuming the source knows more than me, that this is due to the indentation system. One screwy thing done as a result of another screwy thing.

There are a lot of nice things about Python. The code is clean and understandable. It sometimes allows you to do in 2-3 lines what might take 10 lines in another language. And so on. But some programmers feel certain aspects of it are drawbacks, and these things are not easily dismissable. If they were, they would not be brought up again and again.




So technically not "do/while", but:

  while(some_condition):
    do_stuff


No, it's actually this:

  do_stuff
  while(some_condition):
    do_stuff
The advantage of do/while in this situation is avoiding the duplicate code.


I prefer:

    while True:
        codeHere()
        if shouldStop():
            break


More like:

  do_stuff
  while(some_condition):
    do_stuff


Ahh yes - point taken.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: