Live data from Hacker News

I'm switching to Python and actually liking it

cesarsotovalero.net

581–590 of 718 posts

Re: I'm switching to Python and actually liking it

#581
post #509
post #46

I'm glad someone else discovered they can like python. I got forced to learn it for a project where I was proposing Ruby and the customer insisted on Python. This was years ago when Ruby was much slower. I was annoyed but I got used to it and here I am enjoying it many years later. I take issue with the description and use of make though! :-D What is the point of it if you're not going to use dependencies? One might…

Ruby's syntax is much nicer. I just can't stand the idea of using whitespace for scope delimiting.

Ron Garrett noticed that emacs can use "pass" like a closing brace for auto-indenting.

Genius.

Re: I'm switching to Python and actually liking it

#582

I make projects following almost identical patterns. It's a little uncanny. Maybe the people in the python developer ecosystem are converging on a pretty uniform way to do most things? I though some of my choices were maybe "my own", it seeing such consistency makes me question my own free will. It's like when people pick a "unique" name for their baby along with almost everyone else. What you thought was a unique na…

as though subsurface pilot waves in every spectrum hold human egos as constituent particles - becoming-being lol

It is the side of ice cream that makes all the difference for the improbability drive.

Re: I'm switching to Python and actually liking it

#583
post #522

> So yeah, Python is powerful, and it couples very well with the now ubiquitous VSCode editor. I always found vscode lacking for Python and C compared to pycharm and clion. The latter just work without fiddling with config files.

Funny enough I feel the other way about JetBrains IDEs. They * seem * super powerful, but there is always a lot of config that needs to go into them if I'm doing app, infra, and pipeline work. (Edit, not saying they aren't powerful, just more that as coming into them I'm never sure how to wield it the best out of the box) In my experience (not saying this is universal), the folks that like JetBrains IDEs came from ja…

Jet brains was so slow on my machines that I got to experience the speed of a physical teletype, decades after they went out of fashion.

Re: I'm switching to Python and actually liking it

#584
post #522

> So yeah, Python is powerful, and it couples very well with the now ubiquitous VSCode editor. I always found vscode lacking for Python and C compared to pycharm and clion. The latter just work without fiddling with config files.

Funny enough I feel the other way about JetBrains IDEs. They * seem * super powerful, but there is always a lot of config that needs to go into them if I'm doing app, infra, and pipeline work. (Edit, not saying they aren't powerful, just more that as coming into them I'm never sure how to wield it the best out of the box) In my experience (not saying this is universal), the folks that like JetBrains IDEs came from ja…

"Just work" is certainly subjective, but the introspection in all the JetBrains products are what make them ferocious. If one has never heard of all the 18 quadrillion lint tools before, you can immediately get value from opening a file in PyCharm and having it point out the ways it is going to fail on you, including one of my favorite tricks that no VSCode+lint horseshit has ever thought about trying:

  import re
  import sys
  if re.match(r"[A-Za-z}", sys.stdin):
      print("ok")
PyCharm will spot that error immediately, no insaneo configuration required

PyCharm Professional also gets into the SQL side of things:

    with connect(":memory:") as conn:
        c = conn.cursor()
        c.execute("SELECT * FROM oops WHERE NAME IN ('alpha, 'beta')")
instantly spotted, no configuration required

I was going to be cute and use json.loads as an example, but it seems somewhere along the way they botched the fact that the first argument to json.loads is a fucking JSON string. But, it does allow showcasing that you can have PyCharm syntax check the "inner" language of any string literal you'd like via their language injection annotations:

  import json

  # language=json
  bogus = """{"this is subtly wrong"; true}"""

  json.loads(bogus)

  # and the same with tomllib:

  import tomllib
  # language=toml
  bogus = """
  [alpha]
  beta = []onoz
  """
  tomllib.loads(bogus)

  # or, if you have some tricky internal stuff

  def do_the_thing(
    # language=sql
    s: str
  ):
      with connect(something) as conn:
          c = conn.cursor()
          c.execute(s)

  do_the_thing("SELECT * FROM oops WHERE NAME IN ('alpha, 'beta')")
  #            ^^^ also gets syntax checked because it knows the first arg is SQL

Re: I'm switching to Python and actually liking it

#585

Earlier quoted context omitted.

This isn't really unique to the walrus operator, it's just a general python quirk (albeit one I find incredibly annoying). `for i in range(5): ...` will leave `i` bound to 4 after the loop.

> `for i in range(5): ...` will leave `i` bound to 4 after the loop. reply This "feature" was responsible for one of the worst security issues I've seen in my career. I love Python, but the scope leakage is a mess. (And yes, I know it's common in other languages, but that shouldn't excuse it.)

I would love to hear about the security issue if you're able to talk about it

Re: I'm switching to Python and actually liking it

#586
post #305

Earlier quoted context omitted.

The funniest thing for me is that you can use uv in mise to install Python cli programs in a surprisingly elegant manner.

Just curious: how?

You can do it with various mise commands, but the simplest way is to use a mise.toml that looks something like this

  [tools]
  python = latest
  uv = latest
  "pipx:yt-dlp" = latest

  [settings]

  [settings.pipx]
  uvx = true

  [settings.python]
  uv_venv_auto = true
These are all features of the [pipx backend] for mise, and the docs discuss what to do in the case of things like python updates, etc. The advantage of doing it this way, particularly for a global mise config, is that you treat these python tools as basically any other mise tool, so their versioning is easy to control.

I know mise isn't really a package manager. But with its support for things like this, be it for python, ruby, npm, or cargo, as well as more universal support from things like Ubi and the upcoming github backends, its rapidly becoming my favorite package manager. I've a number of projects that use particularly useful node based tools, like markdown-lint or prettier, that aren't JS based in any way, shape, or form. Having to carry around a package.json felt weird, and with the way mise handles all of it, now I don't have to

[pipx backend]: https://mise.jdx.dev/dev-tools/backends/pipx.html

Re: I'm switching to Python and actually liking it

#587

I wonder what the poor guy is switching from.

Java, JavaScript, and R, according to a footnote in the article. Which - to be entirely honest - sharply coloured my view of the preceding article.

"I went from being fully covered in mud to only being half covered in mud, and it's great! I don't understand why people complain about being half covered in mud."

Re: I'm switching to Python and actually liking it

#589
post #319

Earlier quoted context omitted.

Oddly enough, "except" variables don't remain bound! try: x = int('cat') except Exception as e: pass print(e) # So, it appears Python actually has three variable scopes (global, local, exception block)?

> Oddly enough It's not that odd, since it's the only situation where you cannot keep it bounded, unless you enjoy having variables that may or may not be defined (Heisenberg variable?), depending on whether the exception has been raised or not? Compare with the if statement, where the variable in the expression being tested will necessarily be defined.

Heisenbug is the word you are looking but may not find.

Re: I'm switching to Python and actually liking it

#590
post #319

Earlier quoted context omitted.

Oddly enough, "except" variables don't remain bound! try: x = int('cat') except Exception as e: pass print(e) # So, it appears Python actually has three variable scopes (global, local, exception block)?

> Oddly enough It's not that odd, since it's the only situation where you cannot keep it bounded, unless you enjoy having variables that may or may not be defined (Heisenberg variable?), depending on whether the exception has been raised or not? Compare with the if statement, where the variable in the expression being tested will necessarily be defined.

Are you saying that this should result in a name error?

   if :
       x = 5
   print(x)  # 
Post reply on HN