Live data from Hacker News

I'm switching to Python and actually liking it

cesarsotovalero.net

651–660 of 718 posts

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

#651

Earlier quoted context omitted.

While somewhat true, what would this be bound to? for i in range(0): pass

Well, after writing my comment, I realized that a python interpreter could define the variable and set it to None between the guarded block and the except block, and implicitly assign it to the raised exception right before evaluating the except block, when the exception as been raised. So technically, it would be possible to define the variable e in GP example and have it scoped to "whatever is after the guarded blo…

The answer is: it is unbound. Intellisense will most likely tell you it is `Unbound | ` when you try to use the value from a for loop. Would it be possible that it could be default initialized to `None`? Sure, but `None` is a destinctivly different value than a still unbound variable and may result in different handling.

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

#652

Earlier quoted context omitted.

What makes TypeScript better than Python? I don't get it..

Much more capable and reliable type system, paired with comparatively sane package management. This is getting better in the Python world (thank you Astral), but it's still not anywhere near the same.

Not sure if it's worth selling your soul to Microsoft.

I will stick to other languages when I need a better type system.

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

#653

Earlier quoted context omitted.

you could say the same thing about a dozen other languages, but there is definitely a stereotypical cranky java dev that is frustrated writing corporate crud apps that should in theory be blazingly fast, but never quite are for reasons. They revel in the verbosity, and look down on anyone they feel is taking the easy path. If you've never met one you're lucky, but they've been at every company I ever worked for.

> you could say the same thing about a dozen other languages No, you could not. You could say it about maybe four others: PHP, C, C++, and C#. No other languages have anywhere near the userbase size while being fairly quiet when it comes to online tech discussion. I agree there are crusty old Java devs (as well as crusty old C, C++, PHP, etc. devs). In a decade or two, there will be crusty old TypeScript devs. It's j…

ok I may have exaggerated, but there are quite a bit of people silently writing and maintaining mission critical code in Fortran, Lisp, Cobal, Perl, Pascal, R, Assembly, the different BASICs, Lua, TCL, Erlang, and the list goes on. Plus those are just the ones off the top of my head where I have personally met people doing it in the last decade. I am always shocked by how much

Most of those rarely make to the top of HN, and other generalized forums. If anything, Java and Python are together at the popular kids table and we forget about the silent heros keeping the ship afloat.

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

#654
post #392

Maybe I'm the only one that finds Python simultaneously verbose and lacking? Either you need 500 dependencies to do something in a simple way, or you need dozens (if not hundreds) of lines to do trivial things. I avoid writing Python because there's so much bullshit to add. Much prefer Perl, I can actually get things done quickly. Python feels like programming for the sake of programming.

I have a bunch of zero dependency projects. You can get a lot done with the standard library and single file projects which you can run on most systems without needing to do anything except curl it down and run it since Python is available. For example here's a ~2k line Python project which is a command line finance income and expense tracker: https://github.com/nickjj/plutus/blob/main/src/plutus It uses about a doze…

Argparse is part of my problem with Python! I can never remember the weird ways it wants to collect all these attributes and features, so I'm always leafing through manual pages or googling for examples. Same for if I'm modifying existing Argparse code, I have no idea how to make it do what I want. It can do a lot for you, but it's a pain in the ass to use.

It's so much easier to write a simple usage() function that has all help text in one big block, and Getopt with a case block. Anyone can just look at it and edit it without ever looking up documentation.

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

#655

Maybe I'm the only one that finds Python simultaneously verbose and lacking? Either you need 500 dependencies to do something in a simple way, or you need dozens (if not hundreds) of lines to do trivial things. I avoid writing Python because there's so much bullshit to add. Much prefer Perl, I can actually get things done quickly. Python feels like programming for the sake of programming.

> Much prefer Perl, I can actually get things done quickly Python lets you just nest data structures without having to twist your brain. You want a tuple in a list in a dictionary value: you just write it down and can access it with a unified notation. Bam. No reference madness and thinking about contexts. It's a big part of what I typically need to get things done quickly and understand how I did it 5 years later. T…

Perl also lets you nest data structures, no brain twisting involved. Perl doesn't have Tuples natively but you can add them with a module. You can also nest objects in complex data structures.

  perl  "here we go", foo => $object );
  my @array1 = ( undef, undef, undef, \%hash1 );
  my %hash2  = ( bar => \@array1 );
  my $reference = \%hash2;

  print( $reference->{bar}->[3]->{baz}, "\n" );
  print( $reference->{bar}->[3]->{foo}->('thingy') , "\n" );
  print( $reference->{bar}->[3]->{foo}->('something') , "\n" );
  EOF
  here we go
  hello world!
  goodbye world!
Perl being Perl, TMTOWTDI, but you can enforce your own style using linters and formatters.

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

#656
post #541

Earlier quoted context omitted.

Or API_KEY = os.environ.get("YOUTUBE_API_KEY") CHANNEL_ID = os.environ.get("YOUTUBE_CHANNEL_ID") assert(API_KEY, "Missing YOUTUBE_API_KEY") assert(CHANNEL_ID, "Missing CHANNEL_ID")

Assertions are disabled via `python -O` so they probably shouldn't be used like this.

On the other hand, presumably the program will just crash anyway with some terse permission/request error later on if these values aren't set

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

#657

Earlier quoted context omitted.

I was talking about pip, not venv. I don't use venv either, not because I think it's a bad idea but because I can't be bothered. Stuff does end up conflicting unless I use Docker (lol) or uv.

As another commenter alluded: It's clear your knowledge of the topic at hand is poor. It's wise to keep silent in such cases.

Oh yeah, pip is actually right, and everyone is using it wrong

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

#658
post #492
post #458

Earlier quoted context omitted.

I won't touch Python either, but because I've been burned debugging large Python programs. Something that would have taken a minute in a statically typed language took hours of tracing data through the program to understand what was supposed to be in a dict. There are alternative languages that are pithy, statically typed, can write programs quickly, and can grow into large code bases that are maintainable; so there…

Most python written at a large scale uses types (TypedDict) and/or Pydantic for safety and never plain dict objects. That's a code smell in any language, we can stuff data into `map[string]interface{}` all day long and cause problems downstream.

There's also dataclass in stdlib

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

#659
post #458
post #141

Earlier quoted context omitted.

I have a silly theory that I only half joke about that docker/containers wouldn't've ever taken off as fast as it did if it didn't solve the horrible python dependency hell so well. You know something is bad when fancy chrooting is the only ergonomic way of shipping something that works. My first taste of Python was as a sysadmin, back in 2012 or so, installing a service written in Python on a server. The dependency…

I won't touch Python either, but because I've been burned debugging large Python programs. Something that would have taken a minute in a statically typed language took hours of tracing data through the program to understand what was supposed to be in a dict. There are alternative languages that are pithy, statically typed, can write programs quickly, and can grow into large code bases that are maintainable; so there…

It's fine if the author doesn't choose to do horrendous things. There are types too if you want them, but I don't.

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

#660
post #458
post #141

Earlier quoted context omitted.

I have a silly theory that I only half joke about that docker/containers wouldn't've ever taken off as fast as it did if it didn't solve the horrible python dependency hell so well. You know something is bad when fancy chrooting is the only ergonomic way of shipping something that works. My first taste of Python was as a sysadmin, back in 2012 or so, installing a service written in Python on a server. The dependency…

I won't touch Python either, but because I've been burned debugging large Python programs. Something that would have taken a minute in a statically typed language took hours of tracing data through the program to understand what was supposed to be in a dict. There are alternative languages that are pithy, statically typed, can write programs quickly, and can grow into large code bases that are maintainable; so there…

I've seen the same thing in .NET and Java where there's 800 layers of interface and impl and it's an adventure trying to find the actual business logic in all the layers of indirection

>so there is never a reason to start a new project with Python today

Nothing else has an ML/data ecosystem that compares. Perl/Go are maybe a distant 2nd

Post reply on HN