News for hackers. Stuff that matters.
Re:Zed now predicts your next edit with Zeta, our new open m... by oneeyedpigeon on Friday February 14, 2025 @05:35AM (#43047010)
Isn't indentation 'non deterministic' in Python? E.g. if I have the following:

    if (foo):
        bar()
    hum()
how can anything other than a human decide if that 3rd line should be indented as it is or by one more level?
Re:Zed now predicts your next edit with Zeta, our new open m... by yurishimo on Friday February 14, 2025 @07:04AM (#43047528)
And this is one reason I still don't understand the use of python in large teams!

I suppose with very good tests, you might be able to catch something like this, but it seems impossible to me how a PR reviewer might catch a "bug" like this and not just assume that it's intentional.

Re:Zed now predicts your next edit with Zeta, our new open m... by DemetriousJones on Friday February 14, 2025 @08:01AM (#43047887)
One of my biggest gripes with python is the fact that the only way to create a local scope for variables is with functions.

I understand if statements not having their own scope for simplicity's sake, but the fact that `with` blocks don't is simply mind-bobbling to me. ``` with open("text.txt", 'w') as f: f.write("hello world") f.write("hello world") # at least the handle was automatically closed so it will give an IO error ```

Re:Zed now predicts your next edit with Zeta, our new open m... by orf on Friday February 14, 2025 @08:11AM (#43047951)
It’s actually very useful to have context managers outlive their with blocks. They are not only used for files:

One example would be a timing context manager:

   with Timer() as t:
      …
   print(t.runtime)
Another example is mocks, where you want to inspect how many times a mock was called and with what arguments, after the mock context manager has finished.
Re:Zed now predicts your next edit with Zeta, our new open m... by DemetriousJones on Friday February 14, 2025 @10:53AM (#43049660)
I know it makes sense in the "scope-less" python philosopy but it still feels weird for me as a scope (ab)user in C++ and has caused me one headache or two in the past
Re:Zed now predicts your next edit with Zeta, our new open m... by DemetriousJones on Friday February 14, 2025 @08:04AM (#43047910)
Sorry for the borked code formatting
Re:Zed now predicts your next edit with Zeta, our new open m... by neongreen on Friday February 14, 2025 @06:01PM (#43054012)
I learned about the `scoping` package today. Idk if it works exactly as I expect from other langs, though.
Re:Zed now predicts your next edit with Zeta, our new open m... by kstrauser on Friday February 14, 2025 @10:38AM (#43049440)
OTOH I’ve written Python professionally for about 25 years and I truly don’t think I’ve ever seen a bug due to accidental mis-indentation like that.
Re:Zed now predicts your next edit with Zeta, our new open m... by lostdog on Friday February 14, 2025 @03:41PM (#43052860)
When I worked in python I made this exact mistake monthly.
Re:Zed now predicts your next edit with Zeta, our new open m... by kstrauser on Friday February 14, 2025 @03:58PM (#43053008)
How, though? Every code editor I've used supports holding indentation at a certain level until you change it, so if you write:

  if foo:
      bar()
and hit enter after the "bar()", it would drop you down so that the next thing you type would be under the "b". It's not really different from using curly brackets from the perspective of typing in code.
Re:Zed now predicts your next edit with Zeta, our new open m... by lostdog on Friday February 14, 2025 @05:27PM (#43053793)
Cut and pasting code to move it around. Every editor was just slightly jittery about keeping the indentation levels consistent.
Re:Zed now predicts your next edit with Zeta, our new open m... by lukaslalinsky on Saturday February 15, 2025 @02:03AM (#43056515)
Completely agree, this is a common argument ever since Python existed. I've also used it for almost 25 years and these kind of indentation errors just don't happen. I see it the same as forgetting closing brace. Python programming writing C code might forget it initially, but C programmer absolutely will not forget it, it's in their muscle memory. And the same applies for dealing with indentation.
Re:Zed now predicts your next edit with Zeta, our new open m... by saghm on Friday February 14, 2025 @06:36AM (#43047343)
Even humans have trouble with that sometimes: https://www.blackduck.com/blog/understanding-apple-goto-fail...
Re:Zed now predicts your next edit with Zeta, our new open m... by oneeyedpigeon on Friday February 14, 2025 @07:03AM (#43047516)
Although, not in Python of course! :)