Not in Lisp! ("foo" "bar") and ("foobar") are lists of length 2 and 1, respectively. (Python copies some bad ideas from C. Another one is having to import everything you use. It seems that since Python is written in C, its designer took it for granted that there will be something analogous to #include for using libraries, even standard ones that come with the language.) Implicit string literal catenation is tempting…
5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)
51–60 of 339 posts
Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)
#52Earlier quoted context omitted.
5% of 'released' software is quite a lot, more importantly it's a class of errors that definitely should not exist. This is a 'bug' in the language effectively there just isn't any real upside. Python has a few of these things, which is really sad.
It's a class of error that would be caught by even the most basic testing. A better title for the article is that 5% of 666 Python repos have typos that demonstrate the code in them that is completely untested. It doesn't matter which language it is: untested code is untested code in any language.
Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)
#53Earlier quoted context omitted.
Misspelling a variable on the lhs of an assignment just causes a new variable to be created with the new name. That's a lot worse in my book.
Isn't that common for all/most languages that don't require explicit typing?
Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)
#54Not in Lisp! ("foo" "bar") and ("foobar") are lists of length 2 and 1, respectively. (Python copies some bad ideas from C. Another one is having to import everything you use. It seems that since Python is written in C, its designer took it for granted that there will be something analogous to #include for using libraries, even standard ones that come with the language.) Implicit string literal catenation is tempting…
Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)
#55Seems expected, as linters can't be sure when it's not intentional. Like this request to pylint: https://github.com/PyCQA/pylint/issues/1589 Is there usually enough context for a linter to make an educated guess?
Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)
#56Earlier quoted context omitted.
I would have thought it would be a no-brainer to just ban it and insist on an explicit + operator. I'm pretty surprised that issue was so flippantly closed.
> I would have thought it would be a no-brainer to just ban it and insist on an explicit + operator. Maybe as a matter of linting. As a matter of language design, I think + for string concatenation is a big mistake; using different symbols for numeric addition and string concatenation is something Perl got right.
But my impression using pylint is that its default settings are wildly opinionated, hence the surprise that this wouldn't have fallen under that umbrella.
Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)
#57Earlier quoted context omitted.
Misspelling a variable on the lhs of an assignment just causes a new variable to be created with the new name. That's a lot worse in my book.
That’s a complaint against the entire type system, nothing to do with misspelling.
Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)
#58Earlier quoted context omitted.
I was going to comment something like "who would even use this?" and then I remembered that I have in fact used that feature :) It's a somewhat "nice" way to write long strings and keep the code from getting too wide. I never did it inside an array, but I found breaking up a long string into smaller ones and wrapping them in parens without a comma was convenient, for things like error messages. But that's just what c…
Why not just use plusses? Or perhaps a join func, which would accomplish the same. I get the use case as you described it, but it just seems like minimal effort to accomplish and have some semblance of explicit/safety.
Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)
#59I am a bit in shock. Accidental string concatenation. Python just lost a lot of reputation in my brain.
I was going to comment something like "who would even use this?" and then I remembered that I have in fact used that feature :) It's a somewhat "nice" way to write long strings and keep the code from getting too wide. I never did it inside an array, but I found breaking up a long string into smaller ones and wrapping them in parens without a comma was convenient, for things like error messages. But that's just what c…
mylongstring = "hello" +
"world"
No idea if python's way of indentations allows this but sounds like it shouldRe: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)
#60Literally the second item in the "Zen of Python" ( https://www.python.org/dev/peps/pep-0020/ ): Explicit is better than implicit. And yet, s = ["one", "two" "three"] will implicitly and silently do something, that is probably wrong most of the time.
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.
There should be one-- and preferably only one --obvious way to do it.
the author used two different ways of hyphenating (three, if you count the whole PEP 20). PEP 20 is clearly not meant to be taken as law. Nor PEP 8. Nor PEP 257.People frequently mistake "one obvious way" with "one way". There are lots of ways to iterate through something, for example, but there is really one obvious way. And the philosophy here still applies: when you read anyone else's python code, the obvious way is probably doing the obvious thing. I think that is the more appropriate takeaway from PEP 20.