Earlier quoted context omitted.
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.
> This change would break a lot of legacy code for no good reason Preventing a bug that occurs in 5% of observed codebases (and anecdotally, happens to me during development all the time) seems like about as good as reasons get. Swapping a perfectly fine print statement for a function, on the other hand… that’s the breaking change in Py3k that’s never seemed worth it to me.
5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)
251–260 of 339 posts
Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)
#252Earlier quoted context omitted.
> 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.
I use it, personally. The other two options I find too aesthetically displeasing: not indenting the string looks bad when it's within an indented block of code, and using join and putting the strings in a list is just too much boilerplate. I will use """ if I don't care about the extra space put at the start of each line by the indentation.
https://docs.python.org/3/library/textwrap.html#textwrap.ded...
or inspect.cleandoc.
https://docs.python.org/3.8/library/inspect.html#inspect.cle...
Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)
#253Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)
#254Earlier quoted context omitted.
I use it, personally. The other two options I find too aesthetically displeasing: not indenting the string looks bad when it's within an indented block of code, and using join and putting the strings in a list is just too much boilerplate. I will use """ if I don't care about the extra space put at the start of each line by the indentation.
I think you want textwrap.dedent https://docs.python.org/3/library/textwrap.html#textwrap.ded... or inspect.cleandoc. https://docs.python.org/3.8/library/inspect.html#inspect.cle...
Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)
#255Just to be clear, the V8 "bug" was in the test runner code and caused mis-parsing of command line options for testing for non-SSE hardware. Not exactly a critical bug.
https://chromium-review.googlesource.com/c/v8/v8/+/2629465/3...
Personally, I prefer uniform lists with leading commas, because it's easier to add and remove lines for later, inevitable refactoring. For example, I prefer:
things = [
'foo'
, 'bar'
, 'baz'
]
This drives some people crazy, but I think it's the One True Way.Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)
#256Earlier quoted context omitted.
You seem to also not know what "not statically typed" means. It certainly does not mean "not properly scoped".
Yes, of course. But you see that no scope keywords exist in Python. But there exists `+` to concatenate strings (too).
Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)
#257Earlier quoted context omitted.
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)
#258Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)
#259Earlier 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.
While I agree, this is somehow something I expect. Implicit string concatenation without operator or function around it sounds just like a terrible idea. It breaks the basic syntax concept of `foo X bar`. On the other hand it is probably very handy with DSLs and things like that.
usage = (
'usage: foo [options] filenames...\n'
' -f force concatenation\n'
' -c for convenience\n'
)
print usage
Edit: forgot to add parenthesesRe: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)
#260Just to be clear, the V8 "bug" was in the test runner code and caused mis-parsing of command line options for testing for non-SSE hardware. Not exactly a critical bug.
The way the bug arrived in that test runner is interesting. It sneaked in mid-review. Possibly bugs added in the middles of code reviews are more likely to get through. https://chromium-review.googlesource.com/c/v8/v8/+/2629465/3... Personally, I prefer uniform lists with leading commas, because it's easier to add and remove lines for later, inevitable refactoring. For example, I prefer: things = [ 'foo' , 'bar' , 'b…
things = [
'foo',
'bar',
'baz',
]
even better? In your case, if you want to add something to the beginning of the list you'll have to modify two lines.