Live data from Hacker News

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

codereviewdoctor.medium.com

311–320 of 339 posts

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

#311

Earlier quoted context omitted.

I'd totally agree - there's been a burst of sort of the perl style stuff (:= ?) to gain relatively small wins. ie, instead of for line in lines: print(line) we are supposed to be using while line := f.readline(): print(line) I've not been super impressed with this type of thing. That said, string formatting is better with f strings. They also rolled back some the forced breakage from trying to force unicode with 3 wh…

> ie, instead of > for line in lines: print(line) > we are supposed to be using > while line := f.readline(): print(line) No, we’re not. Walrus, in loops, IME, is more for replacing this pattern: while True: myvar = get_it() if not ok(myvar): break # code that uses myvar with this pattern: while ok(myvar := get-it()): # code that uses myvar

I still don't see the need for things like the walrus-operator.

All it does is increase line-noise, and for what? So we don't have to write 2 short lines, or save an indentation level somewhere?

There is a good reason why assignments in Golang are not expressions, even though they are in C, and the language is otherwise deliberately close to the mindset of C; The added convenience makes the code much harder to read.

Sure;

    char c;
    while((c = getch()) != EOF) {
        // do something
    }
requires less lines than;

    char c;
    while(1) {
        c = getch();
        if (c == EOF)
            break;
        // do something
    }
but it's also easier to read, because each line carries less information. That's what people call "line noise".

IMO, := is a step in the wrong direction, and sadly I see python take more and more of these, going from the deliberately simple and clear language to something that's becoming needlessly hard to read by piling on things it doesn't even need.

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

#312
post #303

Earlier quoted context omitted.

You started talking about "adding strings" in a thread about adjacent literals, without mentioning any + operator.. String catenation ("adding") by adjacency (no visible operator) is a thing; "add" doesn't imply that we are talking about a + operator: $ awk 'BEGIN { x = "abc-" 2 + 2 "-def"; print x}' abc-4-def

Because the parent compared Python's behavior to that of C. The difference of course is that adding strings doesn't make sense in C, so there's no danger of misinterpreting "abc" "def" in C, as there is in Python.

The same comma typo bug could happen in C.

  execl("/bin/sh", "/bin/sh", "-c"
        "echo foo", (char *) NULL);
Here we get one "-cecho foo" argument passed to the shell instead of two, so it can't work.

Initializers are another example:

  char *strArray[] = {
    "how", "now"
    "brown", "cow"
  };
In non-variadic function and macro calls, you will most likely get an insufficient arguments error, unless another mistake compensates for that.

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

#313

Earlier 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()

Exit or sys exit kills the kernel, so for explorative programming in like spyder it is not that useful.

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

#314

Earlier quoted context omitted.

>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()

Exit or sys exit kills the kernel, so for explorative programming in like spyder it is not that useful.

Are you looking for breakpoint()?

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

#315
post #299

Earlier quoted context omitted.

On the other hand a good type system doesn't: # let ch_arr = [ "uno"; "dos" "tres"; ];; Error: This expression has type string This is not a function; it cannot be applied.

This is not a good type system. It's a bad language where you can invoke functions without parentesis

Why should function arguments be delimited by parentheses? We don’t do that in Bash or Objective-C, for example

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

#316
post #299

Earlier quoted context omitted.

This is not a good type system. It's a bad language where you can invoke functions without parentesis

Why should function arguments be delimited by parentheses? We don’t do that in Bash or Objective-C, for example

to be able to detect the difference between "this expression is a function" and "this expression is the result of the computation of a function"

the parentheses are not for function arguments, are for "invocation".

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

#317

Earlier quoted context omitted.

"def" is not a function. It's not even an identifier.

This exercise requires you to imagine a somewhat different Python in which you can (and must) do from python import def if you are to use def.

I mean, that would be Lisp, and in that context I wouldn't really have a problem with it.

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

#318

Earlier 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?

It is common tonall languages that have the same syntax for definitions and mutation.

In Scheme, for example, this is not an issue.

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

#319

Earlier quoted context omitted.

The problem is `fop` should be `foo`: foo = 5 fop = 6 Keywords like `let` solve this problem: let foo = 5 fop = 6 # error

Not entirely: let foo = a(); let foo = b(foo); let fop = c(foo); let foo = d(foo); (Which is valid, e.g., in Rust.)

I hate variables shadowing, I'm very surprised that they allowed it in Rust, I saw an unpected behaviour caused by variable shadowing in C++ (global variable hidden by member variable) just last week..

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

#320
post #223
post #88

Earlier quoted context omitted.

JavaScript (strict mode) doesn't have explicit typing, but it still requires variables to be declared.

Same for Perl.

Uh? Perl optionally requires you to declare variables, which is a good idea IMHO, no noise for small script and any experimented Perl programmer will have learned that 'use strict' is a really good idea for big scripts..
Post reply on HN