Live data from Hacker News

I'm switching to Python and actually liking it

cesarsotovalero.net

431–440 of 718 posts

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

#431

Earlier quoted context omitted.

The difference is it's default, it always works the same everywhere, it actually writes down the deps, and I don't have to manually switch between them (or set up fancy bashrc triggers) like venvs.

> it's default This point is true; the ecosystem simply can't change overnight. uv is getting there, I hope. > it always works the same everywhere `uv` works the same, everywhere? > it actually writes down the deps `uv add` does that, too. > I don't have to manually switch between them (or set up fancy bashrc triggers) like venvs. You don't have to do that with `uv`, either?

[deleted]

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

#432
post #80

Just a small note on the code in the linked script: API_KEY = os.environ.get("YOUTUBE_API_KEY") CHANNEL_ID = os.environ.get("YOUTUBE_CHANNEL_ID") if not API_KEY or not CHANNEL_ID: print("Missing YOUTUBE_API_KEY or YOUTUBE_CHANNEL_ID.") exit(1) Presenting the user with "Missing X OR Y" when there's no reason that OR has to be there massively frustrates the user for the near zero benefit of having one fewer if statemen…

Neophytes take notice. Attention to details like this is what separates truly great programmers from merely good ones. That said, for scripts reusable by others you should use command line arguments . Environment variables in lieu of command line arguments is a huge code smell.

For this example, don't just command line arguments. There's an API key there, you don't want an API key visible in your cmdline.

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

#433
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.

> Compare with the if statement, where the variable in the expression being tested will necessarily be defined.

    if False:
        x = 7
    print(x)

    print(x)
          ^
    NameError: name 'x' is not defined
Ruby does this sort of stuff, where a variable is defined more or less lexically (nil by default). Python doesn't do this. You can have local variables that only maybe exist in Python.

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

#434
post #79
post #71

Earlier quoted context omitted.

Can you elaborate bit what is the problem here? Is it shape of the characters or something else?

Amazing. If you need to ask this question I am guessing you have spent too long with Python . No other language uses this underscore madness for special methods or otherwise. Because it’s just , I don’t know a more appropriate word for it , stupid.

Most C and C++ compilers use similarly named macros:

https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macro...

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

#435

Earlier quoted context omitted.

For shadow IT, anything that requires "installation" vs. being in the base system or being added as a file to a project is an inconvenience. It's why I like using Bottle for small Python frontends: download the file and import. (I'm ranting based on personal experiences with IT in the past. Yes in general virtualenv is the baseline)

Compile python to executable is always an option.

If you're dealing with a managed system, chances are, compilers are banned. You'll have to be unsafe and work outside the constrained environment - potentially violating policies, contracts, regulations and laws.

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

#436
post #73

Earlier quoted context omitted.

Python's success is entirely due to entry-level programming courses. They all switched to Python, because you have to explain less. I don't think I heard about web servers in Python before 2012. I suppose a 2005 computer wouldn't be able to serve a Python backend smoothly. PHP's popularity isn't really from 2005-2006. It was popular at the end of the 90s, and it looks like JS as much as it looks like a potato.

> They all switched to Python, because you have to explain less I think this could be generalized to ergonomics. Java 1.6 is an absolute nightmare for a newb compared to Python. No top-level statements, explicit typing, boxing, verbose declaration syntax, long import statements, curly braces everywhere... and, most importantly, no out-of-the-box REPL. Java has since made strides and borrowed from Kotlin and Lombok bu…

> but my understanding is that it was too little too late.

Too little too late to be the #1 language of choice for serious server-side software that it is today?

The weird thing about Java is that people naturally compare its popularity today to its dominance in the early '00s, which was an aberration. The ecosystem has long since returned to its fragmented self, and while Java is not nearly as dominant as it was during that very short period, no other language is, either.

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

#437
>> I prefer to use a monorepo structure

There is nothing more annoying than tons of little repos all of which containing tiny projects with a few hundred lines of code but (of course) you need most / all of them to do anything. Use a mono repo until there is some obvious reason to split it up imo.

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

#439
post #245
post #183

Earlier quoted context omitted.

you'd be crazy (senior or not) not to use Go for Go stuff and Python for Python stuff

I use both, with a preference for Go but I feel like I should be doing more Python just to keep it fresh. It seems like two of the main entries under “Python stuff” are “working with people who only know Python” and “AI/ML because of available packages.” What are some others?

I mean... to oversimplify a bit, Python is for scripting and Go is for servers.

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

#440

>> I prefer to use a monorepo structure There is nothing more annoying than tons of little repos all of which containing tiny projects with a few hundred lines of code but (of course) you need most / all of them to do anything. Use a mono repo until there is some obvious reason to split it up imo.

in my experience, repo by "area" works the best. This usually means by team, but you don't want a team restructure to cause code relocation issues. And, yes, only when the org pressures push for it.

On the flip side, we have an org with 50+ teams and our operations team is pinning for a monorepo. They are just fine with one team's push forcing N teams to have an unexpected deploy and recycling of caches, connections, etc. Not to mention what will happen when team A doesn't have time to deal with team B's merge due to other org pressures.

Post reply on HN