7 ms·
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
by fit2rule 8y ago
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.
- patejam 8y agoThe 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.
- rabidrat 8y agoIt's also basically impossible to cut-and-paste code from a web forum. Was that "else" from the inner or the outer "if"?
- gerdesj 8y agoThat could be considered a feature. At least you have to read what you have copied and pasted.
- rabidrat 8y agoThat'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.
- gerdesj 8y agoIt 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.
- Retra 8y agoYou'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.
- deleted 8y ago[deleted]
- thedirt0115 8y agoI 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.
- bsg75 8y agoI would suggest this is more of a forum software problem than a Python problem. Stripping indentation damages the readability of code in any language.
- lamontcg 8y agoAlso makes auto formatting very difficult when whitespace indentation doesn't just affect readability but syntax.
- sametmax 8y agoUse black. It just works.
- patejam 8y agoI 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.
- acdha 8y agoWhat editor are you using? This just works in VSCode, vim, TextMate, etc.
- int_19h 8y agoHow 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).
- Doxin 8y agoMake 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.
- LBarret 8y agoyes, but that's so minor compared to the gain of a more readable syntax... really an edge case.
- gsich 8y agotabs would be much better, but unfortunately pep8 dictates spaces.
- zinckiwi 8y agoFor submissions to the language. For your own stuff, knock yourself out and tab away.
- lisper 8y agoPython has open-braces in the form of colons. If you use emacs, you can use the PASS statement as a close-brace and everything will auto-indent properly. Python purists have conniptions when they see this programming style, but I've used it for nearly 20 years and it works for me.
- rrmm 8y agoI usually close blocks with "#end <whatever>". It doesn't automatically format, but it at least makes it clear to me should the formatting get messed up. I keep thinking about changing the emacs mode to respect this, but it never causes enough of an issue to make me do it.
- cutler 8y agoI found Python's indentation style more appealing after working with Clojure for a while. Python is a bit like lisp without the parentheses. In fact you can Clojurify Python with Hy (http://hylang.org http://hylang.org) which solves both the indentation problem and the crippled lambdas problem.
- armitron 8y agoPython is nothing like Lisp, where did you come up with that? Three things that are key in Lisp: Symbols, environments and lexical scope. Python has none of these.
- lispm 8y agoPython reminds me more of an object-oriented BASIC. Mostly imperative control flow. Lots of assignments. Lots of state manipulation.
- kazinator 8y agoPerhaps the biggest computer science cluster-fuck in Python is that there is no syntactic distinction between instantiating/binding a variable and assigning to it. Python 3 makes it worse by adding some declarative stupidies nonlocal and global: https://en.wikipedia.org/wiki/Variable_shadowing#Python https://en.wikipedia.org/wiki/Variable_shadowing#Python
- kazinator 8y agoMost of the examples of Python program design that are held up as "Pythonic" can be described as Fortran with dynamic typing.
- perfunctory 8y agoI used to have a similar aversion to significant whitespace having learned in compiler classes that space should be insignificant. Over time I learned to appreciate the significant indentation though and now I want a C frontend with similar syntax.
- elcritch 8y agoTry Nim, pretty much a Python-esque front-end for C. Personally I really miss defining for-loop index cars in the for-loop syntax.
- enriquto 8y ago> but for me, Lua is just far more elegant, It's curious... Lua is my favorite language due to its elegance, but I would love it even more if it used significant indentation (using tabs, of course) instead of "end" blocks.
- sebcat 8y agoOTOH, I would love Python even more if I could do: x = function(x) return x*x end and not use those awful Python lambdas... Not that it really matters though, bridges still get built.
- aldanor 8y agoYour example is already doable without lambdas: def f(x): return x * x
- sebcat 8y agoTo clarify: the point I was trying to make was that the explicit 'end' in Lua allows for closures that are more nice (subjective) than Python lambdas. Something both JS and Lua got right, but with which Python ended up with a much more limited syntax.
- klibertp 8y agoThe lambda syntax is not what makes it less nice - it's the fact that they are limited to a single expression. Being indentation-based has nothing to do with that restriction: Nim manages to use indents and to have multiline lambdas at the same time.
- enriquto 8y agoit looks a bit perverse to use the same name for the function and for its argument, but maybe it's just me
- sebcat 8y ago
- codezero 8y agoThis is way off topic, but I’ve never seen the word goosebridle - googling it comes up with a phrase a wigwam for a goose’s bridle - and there its usage is meant as a rejoinder meaning “none of your business” - I’m curious how it ended up as a word to mean - I’m guessing - flashy features (jeez now I am sure there is a more common word for that) - is this a local thing, or is the etymology on the web wrong, what I’m saying is I’m curious how your usage of the word came about :)