Most active commenters

    ←back to thread

    2024 points randlet | 18 comments | | HN request time: 0.001s | source | bottom
    Show context
    theandrewbailey ◴[] No.17516370[source]
    Python was my first programming language, ~15 years ago. The bracket- and semicolon-free syntax is beautiful and approachable to this day. Python is my go-to for writing data format conversion scripts. I wrote a random sentence generator in Python 10 years ago that gave me and my friends hours of entertainment.

    Thanks, Guido, for the good times!

    replies(1): >>17517645 #
    fit2rule ◴[] No.17517645[source]
    I can never get into Python and end up with as much passion as you. For me, its a very powerful and useful language - no doubt about it.

    But the aesthetics of a whitespace language just don't jive with my 30+ years of experience writing code. No matter how many times I try over the past few decades, I just can't get passionate about writing Python code. I know its power, and I totally grok its value to our industry - but for me, Lua is just far more elegant, even if it doesn't ship with all of Pythons' goosebridles. Lua is my go-to scripting language; I only ever use Python if I have to - i.e. its enforced on me by others.

    I really do try to get over this personal handicap, often enough, but the moment I have to start thinking about indentation I just lose all the passion and it starts feeling like a drag. What a dilemma, because I know it has been used for many, many great things .. I just wish I could get over my aversion to white-space'ing things all the time. I've tried editor after editor (well, expect the Python-specific things), but it just doesn't click.

    Ah well.

    replies(6): >>17517931 #>>17519165 #>>17519828 #>>17521140 #>>17521516 #>>17535913 #
    1. patejam ◴[] No.17517931[source]
    The indentation should be almost the same as any other language. Unless you have an aversion to consistent code-style.

    Python whitespace was only annoying for me years ago when it still had trouble handling tabs and spaces in the same file, and you would run into literally invisible bugs. I haven't run into that in a long time, though.

    replies(2): >>17518007 #>>17520705 #
    2. rabidrat ◴[] No.17518007[source]
    It's also basically impossible to cut-and-paste code from a web forum. Was that "else" from the inner or the outer "if"?
    replies(7): >>17518208 #>>17518298 #>>17518902 #>>17518922 #>>17519764 #>>17521294 #>>17542022 #
    3. gerdesj ◴[] No.17518208[source]
    That could be considered a feature. At least you have to read what you have copied and pasted.
    replies(1): >>17518372 #
    4. lamontcg ◴[] No.17518298[source]
    Also makes auto formatting very difficult when whitespace indentation doesn't just affect readability but syntax.
    replies(1): >>17518642 #
    5. rabidrat ◴[] No.17518372{3}[source]
    That's cute but I hope no one reading this thinks you are being serious. If they do, to wit:

    So many webforums strip leading indents from code. It's not like it looks right on the forum, and then gets inserted into your editor wrong. It's often not right on the source side either. So if you're trying to learn an algorithm from the Python code, you're SOL. This has happened to me.

    replies(5): >>17519602 #>>17520400 #>>17521870 #>>17528247 #>>17535193 #
    6. sametmax ◴[] No.17518642{3}[source]
    Use black. It just works.
    7. patejam ◴[] No.17518902[source]
    I have problems in a lot of languages copy-pasting code (why are the line numbers being copied!?), but yes this is another problem for this specific language.
    8. acdha ◴[] No.17518922[source]
    What editor are you using? This just works in VSCode, vim, TextMate, etc.
    9. gerdesj ◴[] No.17519602{4}[source]
    It isn't cute at all and I am quite serious. It is an accident that Python syntax pitted against sufficiently unsophisticated code displayers causes copy n paste breakage.

    However, that breakage does mean that you have to at least read the code a bit. You either get to avoid a potential security flaw or gain a deeper understanding of an algorithm.

    Fixing syntax does not break your ability to learn an algorithm but it will get you closer to its description.

    With Python you are generally SIL not SOL.

    10. int_19h ◴[] No.17519764[source]
    How so? If the code was properly indented on the forum, it'll still be properly indented when you paste it. The only thing you'll need to do is to make sure that indentation of the entire pasted block is consistent with whatever's around it... but pretty much any editor these days, at least the ones meant for code, let you easily adjust indentation of an arbitrary selection (just highlight and Tab or Shift-Tab as needed).
    11. Retra ◴[] No.17520400{4}[source]
    You're not SOL. You just have to retype or reformat the code. Given that you're trying to learn, you should have started with that step anyhow.

    I've been writing Python for years and never had this problem.

    12. gsich ◴[] No.17520705[source]
    tabs would be much better, but unfortunately pep8 dictates spaces.
    replies(1): >>17521066 #
    13. zinckiwi ◴[] No.17521066[source]
    For submissions to the language. For your own stuff, knock yourself out and tab away.
    14. Doxin ◴[] No.17521294[source]
    Make sure you copy the whitespace on the first line as well and then it's just a case of indent/dedenting the whole section of pasted code to match.
    15. ◴[] No.17521870{4}[source]
    16. thedirt0115 ◴[] No.17528247{4}[source]
    I find this hard to believe. Searching for python copy paste indentation, the first page of results has everything from how to turn it on for various editors to how to turn it OFF for various editors (implying it's built-in to some). If you just gave up 5 seconds after pasting because it didn't look right or work immediately and you didn't even try looking for help... I dunno what to say.
    17. bsg75 ◴[] No.17535193{4}[source]
    I would suggest this is more of a forum software problem than a Python problem. Stripping indentation damages the readability of code in any language.
    18. LBarret ◴[] No.17542022[source]
    yes, but that's so minor compared to the gain of a more readable syntax... really an edge case.