Earlier quoted context omitted.
The official package manager is pip, it's broken, and there has been a new "permanent solution" replacement for it each year.
Poetry has been decent for years. uv is new but great and will likely continue to be.
I'm switching to Python and actually liking it
471–480 of 718 posts
Re: I'm switching to Python and actually liking it
#472>> 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.
For personal projects, though, I get the value of an actual small projects monorepo.
Re: I'm switching to Python and actually liking it
#473Earlier quoted context omitted.
> it's obvious that they are magic methods and not intended to be part of the public API Is there an alternative API? No. This is public API regardless of anyone's intentions. Though "it's weird" is really not a very strong argument against it.
There are several alternative API's. @dataclass is one, Pydantic offers another, there's also attrs, plus less general things like namedtuple. Admittedly it's obnoxious when you've got habits for one and you're on a team that uses another--totally flies in the face of the zen re: "there should be only one obvious way to do things". ...but that was always a rather ambitious goal anyway. I'm ok navigating the forest of…
Re: I'm switching to Python and actually liking it
#474Re: I'm switching to Python and actually liking it
#475Earlier 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.
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)?
edit: writing from phone on couch and the laptop... looks far, far away...
Re: I'm switching to Python and actually liking it
#476Maybe 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.
Re: I'm switching to Python and actually liking it
#477Earlier quoted context omitted.
> Have you considered how much familiarity might shape your reaction to the two? It doesn't. > Both are specific patterns with arbitrary restrictions which new learners have to internalize, and that’s a fairly advanced task most people won’t hit until they are familiar with the language syntax. No, the Python methods are just ordinary methods with valid names. What 'arbitrary restrictions' are you referring to?
The arbitrary restriction is that you have to just learn a specific pattern and follow it. I can’t have my Python class use “addition” if I hate underscores or my C++ code use “mathematical_division” if I’m horribly pedantic. In both cases, it’s just a particular design decision by the language developers I have to learn, and in both cases I won’t think much of it after the initial acclimation.
C++ it’s just one pattern to learn, x -> operatorx
Re: I'm switching to Python and actually liking it
#478Just 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…
This is nitpicking, but this is a good usecase for the := operator: if not (API_KEY := os.getenv("API_KEY")): ... For internal tools I just let os.environ["API_KEY"] raise a KeyError. It's descriptive enough.
Re: I'm switching to Python and actually liking it
#479Coming from a mathy background I found it incredibly satisfying, although I’ve come around to other languages since.
Re: I'm switching to Python and actually liking it
#480Earlier quoted context omitted.
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.
Then how would you SET the API key in the first place? :) The argument doesn't make any sense at all.