Live data from Hacker News

5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

codereviewdoctor.medium.com

201–210 of 339 posts

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#201
post #41

Earlier quoted context omitted.

The rejection notice seems completely counter intuitive to me. How is adding a plus "harder" compared to removing a foot gun? > This PEP is rejected. There wasn't enough support in favor, the feature to be removed isn't all that harmful, and there are some use cases that would become harder.

This change would break a lot of legacy code for no good reason The most common way to split a string in lines is using this concatenation formula.

> The most common way to split a string in lines is using this concatenation formula.

Is it really? I tend to avoid it in favour of ””” or ‘\n’.join(), because it looks like a mistake.

Triple quotes are kind of annoying if the string is indented, but you can just not indent the string to avoid the whitespace.

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#202

Earlier quoted context omitted.

> it sounds like you're expecting "two" and "three" to be separate list elements I'd expect that to be an error.

Funny enough, in dynamic languages i expect it to do something unexpected and unwanted. This is why i like Go/Rust. I detest the implicit warts of these languages.

Well, there are dynamic languages and dynamic languages. There are Python and Ruby and there are Elixir, Erlang and Lisps.

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#203

The high-level goals of python end up creating these little syntactic landmines that can get even experienced coders. My personal nomination for the worst one of these is that having a comma after a single value often (depending on the surrounding syntax) creates a tuple. It's easy to miss and creates maddening errors where nothing works how you expect. I've moved away from working in Python in general, but I think t…

A lot of people in this thread are using this to make fun of Python, but the exact same issue exists in something like c++, here's some I fixed recently:

https://github.com/UWQuickstep/quickstep/pull/9

https://github.com/tensorflow/tensorflow/pull/51578

https://github.com/mono/mono/pull/21197

https://github.com/llvm/llvm-project/pull/335

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#205

Earlier quoted context omitted.

But wasn't this proposal part of the move to python 3? strings where broken left and right anyway.

Right, there was lots of deliberate breakage, _and_ this is purely syntaxual hence the sort of thing 2to3 could trivially deal with.

> the sort of thing 2to3 could trivially deal with

2to3 could also trivially add +, and if anything, that would actually help surface these kind of bugs, because if you randomly see a + in the middle of your list of strings, it's much easier to spot the bug than if there was a missing comma.

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#207

I like this. It's clearly meant as marketing for their product, but imo the best kind of marketing. They don't just run their tool and automatically make tickets, but check for false positive and (offer to) make pr's. It's both good for those projects and for the company that does the marketing since they reach there exact target group. Plus it gets them on the front page of HN.

A great addition to prune a ton of false-positives is to check the length of the strings. Almost always, the intentional implicit concats will have a very long string that reaches the max line length, whereas the accidental ones are almost always very short strings.

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#208
post #30

Earlier quoted context omitted.

I mean the zen being wrong is kind of a meme at this point. The whole “only one obvious way to do it” isn’t just false but the exact opposite is true. Python is one of the most flexible languages with many many ways to do the same thing; more than any other language I can think of.

> Complex is better than complicated What? Something being complex is artificial, we try to avoid it. Problems can be complicated, we try to simplify them, and more complicated the problem is, we tend to develop more complex solutions. So comparing them does not make sense? Or did I always know them wrong?

It's not particularly well-worded. A lot of dictionaries list complex/complicated as synonyms.

I always took it to mean 'complex' as in having many connected parts, and 'complicated' more as in over-complicated or convoluted - the opposite of 'simple'. In other words, breaking something complicated into a system of intentionally-designed pieces is probably better than a chunk of opaque code to brute-force the current case. A good system is probably also 'simpler', despite having more pieces and interconnects.

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#209
post #150

Earlier quoted context omitted.

the zen of python was written in the 90s. from that context it makes sense, because the only goal of python in the 1990s was to be more popular than perl, which was notorious in having many ways of doing the same thing. but yeah, python had had significant feature creep over the years, it's nowhere near the small clear lang it used to be.

And still no expressive switch/case statement, breaking out of loops and ending scripts early (for explorative programming).

>no expressive switch/case statement

match/case (not a drop in switch statement)

>breaking out of loops

  break
>ending scripts early (for explorative programming)

  exit() or sys.exit()

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#210

I really like the idea of automated code review tools that point out unusual or suspicious solutions and code patterns. Kind of like an advanced linter that looks deeper into the code structure. With emerging AI tools like Github Copilot, it seems like the inevitable future. Programming is very pattern-oriented and even though these kinds of tools might not necessarily be able to point out architectural flaws in a co…

Or people could just write it correctly in the first place! Controversial I know! Seems like people would rather half-ass things and then let some AI autocorrect fix it up for whatever reason rather than doing it properly.
Post reply on HN