Live data from Hacker News

Python Is Eating the World

zdnet.com

871–880 of 993 posts

Re: Python Is Eating the World

#871

Earlier quoted context omitted.

The solution to this is Poetry. https://poetry.eustace.io It's good. Projects should use it.

> curl ... | python Ah goddamnit. 868 lines, including os.rmtree calls and stuff. Also installable via pip, but... "not recommended", and: [RuntimeError] Poetry was not installed with the recommended installer. Cannot update automatically.

They could just as easily add the same code to setup.py, and then pip would run it as soon as you run pip install. There's generally no security difference between curl | python and pip install.

Re: Python Is Eating the World

#872

Recently was trying to convert Python to C#... there are few things that are as absolutely incomprehensible as a Python programmer being clever with numpy. I gave up on the conversion. Perhaps this is a point for Python’s flexibility, but I’d say it’s just a waste. Here’s the code. Try to convert this to any C style language. mins = X.min(axis=0) maxs = X.max(axis=0) idxs = np.random.choice(range(self.dim), self.dim-…

Your challenge isn't possible because the code snippet isn't complete. It doesn't include the definition of 'make_tree', 'Node', or the broader context. That being said, I have no doubt that C++ with Boost would look quite similar to that. The boost libraries have very powerful numeric constructs and can easily handle matrices, uniform random distributions, dot products, and trees.

Well, yeah. My point is the syntax itself is very (too) clever. This syntax is probably possible in C# but you’d be a monster to write it (lots of operator overloads.)

The whole implementation is from an implementation of an extended isolation forest. It’s easy enough to find on GitHub if you’re interested.

Re: Python Is Eating the World

#873

Earlier quoted context omitted.

> Braces define scope unequivocally So does whitespace, otherwise Python wouldn’t work as a programming language > they are easy to visually parse only if you indent properly > Furthermore, you can copy and paste, say for loop from a method to another method and it will work. In Python you might have to faff about with spaces (I'm sure there must be IDEs that solve this problem but it was no fun on vim or even notepa…

If I mix and match spaces and tabs, Python will not work and you cannot tell them apart ,it's a bit more subttle than this, but you get the idea (should you wish to). There is no such issue with braces. This is what i meant. As for formatting, you can use ide shorcuts to format your pasted code but it will run fine even if not formatted, not the same for Python, where it will not run.

[deleted]

Re: Python Is Eating the World

#874
post #377

Earlier quoted context omitted.

Oversensitive? Is the contractor who chooses a Dewalt or Ridgid over a Ryobi for daily work "caring about irrelevant stuff"? A drill is a drill right? Why is it different for us in software?

Hey I like my Ryobi drill. :(

I love my Ryobi tools too! Just, I've assumed given their price-point, they aren't built for day in and day out needs of a contractor.

Re: Python Is Eating the World

#875

Earlier quoted context omitted.

Thanks for posting. I've wondered if it's just me or does anyone else want to leave software engineering because of Python's dominance. There's no arguing against it either because as this thread shows, "I like it for my use case, look at these libraries that let you get X and Y done SOOOO easy, so it must be great for everything."

I've contemplated leaving SE behind because of JavaScript, not because of Python. Do you tolerate JS?

I thoroughly enjoy UI/client development, but the web app tooling (layer upon layer that is supposed to "fix" HTML/CSS/JS every few years) is frustrating to me. Thus, I avoid it like the plague. :)

To be fair, the JS ecosystem I think is a bit more tolerable than Python. JS isn't being promoted far and wide as the good-enough tool for everything like Python is. A lot of JS is focused on the "view", and I can see a dynamic language fitting there (though React/Redux is making me rethink that).

Re: Python Is Eating the World

#876
post #793

Earlier quoted context omitted.

I'm pretty sure this is what they meant... def my_func(): group_keys = 'My thing' while group_keys == 'My Thing': if some_logic() == 42: groups_key = 'My other thing' # typo here

I don't see how that's avoidable in any language that doesn't require explicit variable declaration

compiler/IDE would complain about "unused local variable"

Re: Python Is Eating the World

#877

Earlier quoted context omitted.

The solution to this is Poetry. https://poetry.eustace.io It's good. Projects should use it.

Could you give some details as to why it's better than other more commonly used tools (pip, venv, ...)? Looking at the home page it's not immediately obvious to me. For example, the lock file it creates seems to be the equivalent of writing `pip freeze` to the requirements file. I see a quick mention of isolation at the end, it seems to use virtual environments, does it make it more seamless? What's the advantage ove…

I'm not an expert on the internals, but virtualenv interactions feel more seamless. When you run poetry, it activates the virtualenv before it runs whatever you wanted.

So `poetry add` (it's version of pip install) doesn't require you to have the virtualenv active. It will activate it, run the install, and update your dependency specifications in pyproject.toml. You can also do `poetry run` and it will activate the virtualenv before it runs whatever shell command comes after. Or you can do `poetry shell` to run a shell inside the virtualenv.

I like the seamless integration, personally.

Re: Python Is Eating the World

#878

Earlier quoted context omitted.

You are describing static typing. There is a well defined difference between strongly typed and statically typed.

Could you elaborate or point to a resource? AFAIK, term "strongly typed" is usually used to refer to that the type cannot change but I'm failing to find a well defined definition or the comparison against statically typed.

The word "type" has a specific meaning in maths/logic, which is not the same as that used by the "dynamic" languages community.

Professor Bob Harper of CMU would refer to Python as unityped, i.e. having a single type: https://existentialtype.wordpress.com/2011/03/19/dynamic-lan...

Re: Python Is Eating the World

#879

Earlier quoted context omitted.

I believe that marketing Python as "strongly typed" has the potential to confuse rather than educate. Python still crashes at runtime with these errors. It has nice error messages, but it still crashes, potentially in production. If you want to create your own "types", you'll have to add your own runtime checks. It's much more sane than JavaScript, but it's not strongly typed like Haskell. Python does not automatical…

You are describing static typing. There is a well defined difference between strongly typed and statically typed.

My point is that your marketing is misleading. Use "strong dynamic types" if you must, but for Python, it would be more accurate to say "strongly tagged".

Re: Python Is Eating the World

#880

Earlier quoted context omitted.

Well, this should have been caught as an unused assignment in static analysis. A whole ton of languages allow this situation, so I'm not gonna ding Python too hard for that one. However, here's a related but different python gotcha: if foo(a): v = list(bar(a)) for i in v: print i In this example, v is only defined inside the if. Due to python's limited scopes, v is also valid outside the if, but only has an assignmen…

Indeed, as another user mentions, mypy will detect this issue, as will pytype, even without any annotations.

Interesting, I had not looked at these because I'm not interested in volunteering to add type notations to our code base.
Post reply on HN