Live data from Hacker News

Why People Should Learn Python

iluxonchik.github.io

201–210 of 329 posts

Re: Why People Should Learn Python

#201
post #54

Earlier quoted context omitted.

> Try running a nested loop on a non-trivial example, and you can end up spending minutes in what would take milliseconds in any other language. Huh? Can you provide an example? There's nothing about writing nested loops in Python that is qualitatively different from other languages. > If you want to program in Python, you must get used to the functional paradigm. Not "should", "must". This is incorrect, much to my c…

Show me an example that uses `reduce` with a function other than sum/product that makes it clearer than the equivalent loop.

Reduce doesn't have side effects, handles an empty collection, doesn't need to reference the index of the iterable, and self-documents the code as a fold. I find the last part nice because a loop or a Python comprehension would need to add a comment to explain what would otherwise be clear from the syntax.

Here's an alternative example where I think it makes sense (checking if the size of all elements in a collection are equal):

  reduce(lambda a, b: len(a) == len(b), ls)

Re: Why People Should Learn Python

#202

Earlier quoted context omitted.

Imagine you have a list of products with prices and you want to calculate the cost of all products that are of a certain type. In ruby you can write this as products.select { |product| product.type == 'x' }.map(&:price).reduce(:+)

And in Python you can write something like: sum([p.price for p in products if p.type == "x"]) Excuse untested code from phone, but I like it better than the ruby version.

I find the order of iteration in Python for comprehensions totally confusing every time. If you want to convert:

    for a in x: pass
into a comprehension, you write:

    [pass for a in x]
Simple, right? So to convert

    for a in x: for b in y: pass
I obviously write:

    [pass for b in y for a in x]
Bzzt. Nope, you have to write it in middle-endian order to get the same behaviour.

Re: Why People Should Learn Python

#203
post #177
post #43

I switched to writing python as my main backend/scripting language with my new job. Previously I was using Ruby for most of this stuff with some Go. I must say that so far Python has been a vastly inferior experience for me. The languages are fairly similar all though I prefer the more talkative/english style of ruby and the use of functions over list and dict comprehension. The thing that really stands out to me tho…

Amazing that Python 2 vs. Python 3 has still not yet been sorted out. I dipped my toe into Python a couple years ago when looking for a general-purpose scripting language and quickly gave up in frustration—Python 3 was by far the preferable flavor, but many libraries simply didn't work. I picked up Ruby and haven't looked back.

Likewise...and when I have to work in Python it's a frustrating pain because the tooling is so much better on the Ruby side.

Heck, the tooling is better on the PHP side even...

Re: Why People Should Learn Python

#205
post #128

Why you shouldn't learn Python: 1. In-consistant syntax. 2. The language uses exceptions to control flow of logic. 3. Divided community, since Python 3+ included breaking changes to the standard. 4. Un-discoverable APIs. You better hope the documentation is bulletproof else the API could change in any which way during runtime. 5. Poor error messages. If an import goes wrong you are not told why, and so on. 6. Ultimat…

Reasons to learn Python: Sklearn, tensorflow, pandas, Sqlalchemy, requests, Beautifulsoup, numpy, scipy, pulp. If you have a language that had equivalent libraries that cover all these domains I'd love to hear it. Until then I can build really cool stuff in Python very easily thanks to the amazing hardwork and generosity of these library creators.

If you have a language that had equivalent libraries that cover all these domains I'd love to hear it.

R[1].

[1] https://cran.r-project.org/

Re: Why People Should Learn Python

#206
post #28

Why you shouldn't learn Python: 1. In-consistant syntax. 2. The language uses exceptions to control flow of logic. 3. Divided community, since Python 3+ included breaking changes to the standard. 4. Un-discoverable APIs. You better hope the documentation is bulletproof else the API could change in any which way during runtime. 5. Poor error messages. If an import goes wrong you are not told why, and so on. 6. Ultimat…

Name a single language that covers all those things and has a pretty syntax.

Scala. (Which is why I use it)

Re: Why People Should Learn Python

#207
I hate Python. My linux distro comes with version 2.7 yet I should be using version 3?? Yes it makes writing complex programs quickly with its endless libraries, but I don't consider myself learning anything if all I'm doing is copy pasting the API docs. I've recently switched to Go and the language is small and easy, docs/source code are well commented, and lastly I'm actually learning how computer programs work.

Re: Why People Should Learn Python

#208

Earlier quoted context omitted.

Maybe all your C#/.NET/Java devs can't access HN because their big enterprise businesses have security policies which have blacklisted it? Hah.

.NET/Java is to pay the bills, and we vote for the fun stuff while we create our boiler plate classes.

Exactly. My fun language at the moment is Clojure... I think several years of Java development has made me seriously hate OOP.

Re: Why People Should Learn Python

#209
post #160
post #157

Earlier quoted context omitted.

You're right, of course, this does often happen. Seems to me, though, the issue isn't cutting and pasting something on the web - it's getting it losslessly onto the web in the first place. It's the responsibility of the person posting the snippet to ensure it shows up correctly, and if their chosen platform doesn't support that they should use a better one. This probably reads pedantically, but I do think there's a d…

Yes I would. Requiring a character set outside of ASCII is what I'd call a high-risk design decision, that could easily become a misfeature of a language. Windows "smart quotes" are bad enough and that's not even a programming language. This is why people invented J as an alternative to APL.

Would you say it's "hard to copy and paste Unicode"?

Re: Why People Should Learn Python

#210

I hate Python. My linux distro comes with version 2.7 yet I should be using version 3?? Yes it makes writing complex programs quickly with its endless libraries, but I don't consider myself learning anything if all I'm doing is copy pasting the API docs. I've recently switched to Go and the language is small and easy, docs/source code are well commented, and lastly I'm actually learning how computer programs work.

Most ppl are trying to solve problems/get work done, not learn how to re-implement functionality already available in libraries. Copy & pasting the API docs lets you focus on solving much harder & more interesting problems.

If you want to learn how computer programs work, you don't have to use existing libraries - you can still implement the functionality yourself.

By your argument (I hate python...it has libraries) any modern & moderately successful language with a large library ecosystem is bad, and you prefer Go precisely because it lacks those libraries?

Post reply on HN