6
cprn
3y

So I just realized (while rewriting some code) Python can't import stuff from a sibling directory without voodoo tricks. Seriously. In 21st century.

Comments
  • 3
    Python projects are meant to be structured in a less primitive way
  • 2
    @electrineer Disagree. The way Python projects are structured every directory is at least a namespace package and has to be installed in current environment (ideally) or you need to hack `sys.path` (easy but not good) or you need to wrap everything in a separate package and use absolute imports. It's not "less primitive", it's over complicated and unintuitive.
  • 3
    @cprn primitivity is not always a bad thing
  • 2
    Yep, one of the reasons I'd never use Python for a large project.

    Imports are unnecessarily painful, JSON parsing is a fucking joke and I don't like a script crashing minutes into some processing because it didn't catch a typo before execution. And whoever came up with persistent arrays in default arguments deserves stubbing their toe once a week.
  • 6
    Have you heard of our Lord and Savior, Ruby? 😇
  • 0
    @Root About 5 minutes ago from you in a comment on data structures. 😆 Seriously, though. I think I'll just stick to PHP for web and C++ for everything else. Too much disappointment in "trending" stuff lately.
  • 1
    @cprn Sadness.

    PHO is inherently broken; you really should try something else.
  • 2
    @Root Honestly? It depends. Sadness runs deep in this one. But it's a known sadness. Comfy one. Cherished. Almost bearable when you know how to work around it. Compared to 4 hours of searching for what should be the 1st result on Google, I dare say it's a welcome kind of sadness that I'll wrap myself in and use as a blanket. That and whiskey.
  • 2
    Python assumes that there is only one folder containing all sources, rest is __init__.py adding and be done.

    https://docs.python.org/3/tutorial/...

    Of course you can use sys.path or other stuff... But it's against pythons design principles - if I understand correctly what you want to do.

    Honestly, PHP has become far better the last versions. I was astonished to read that they even add Fiber Support for asynchronous framework support in 8.1 .
  • 2
    First coffee.

    Bit longer explanation: Python is opinionated. I'd go so far to say _the most opionated_ framework.

    I don't like it's design decisions most of the time - for the same reason I think as you, sometimes it's just fuckity... (No prefix operator, eg. idx++ )

    But I dislike the way of working around the design decisions, as it mostly leads to "code non grata" - stuff that works, but you'll never know when it breaks. :(
  • 2
    These autocorrect typos are getting out of hand. đŸ¤ĻđŸģ‍♀ī¸
  • 0
    @Root hm?

    I had to edit a lot of posts lately... Brain is just a dumpster fire.

    What did I do wrong? *sad*
  • 4
    @IntrusionCM Mine. I commented PHO instead of PHP. (Among several other mistakes over my last comments.)

    Someday autocorrect might understand context.
  • 1
    @Root Naaaaa....

    Autocorrect will never work correctly.

    Even when AI start taking over the planet.

    But yeah, you're not alone ;)
  • 1
    @IntrusionCM I just hope it’s a good AI.
  • 3
    @Root on the other hand, pho is absolutely delicious and my favourite noodle soup to both make at home and eat at a restaurant, and your comment reminded me that it's been a whole two weeks since I've had it...time to do some cooking.
  • 3
    @RememberMe Pho is 💜!
  • 2
    @RememberMe I. Hate. You.

    -.-

    Since moving 1.5 years ago I haven't found a good vietnamese restaurant....

    no pho.

    No bun bo nam bo... *sad*
  • 2
    @IntrusionCM try making it yourself? There's a bunch of good recipes online and even a basic one gives you that characteristic pho flavour. If you're in a hurry you can use pre-made stock instead of making it yourself which makes the process considerably easier (but not as good).
  • 2
    @RememberMe might be an idea.

    But home isolation, hence no grocery shopping. :(

    *sigh* never cooked Vietnamese before, would be a first
  • 1
    @RememberMe @IntrusionCM There was a Szechuan place in Vegas that i absolutely loved. Their “cold noodles” were delicious and insanely spicy.

    I miss it.

    I also miss the sushi there. Amusingly the best sushi in Vegas (to me) was right next door to the Szechuan place, so deciding what to eat was always difficult. Now that we’ve moved, nothing here even comes close. Grocery store sushi is about as good as we can get. I’m so not kidding. I’m not a sushi chef, either, so making it myself...? My sushi has never turned out terribly well, so 😭
  • 1
    Order groceries on-line, cook whatever you want, profit. My cooking went through the roof since this home isolation, highly recommended. I feel like my food truck would kill all the other food trucks. In a fist fight. With its bare tires.

    *munching on home made grass fed fully organic lactose free cannamuffin*
  • 1
    @cprn canna...? I want. ☚ī¸

    It’s true though. Using this as a way to practice cooking is 👌đŸģ
  • 2
    Not sure but if you have to import from sibling directory, there must be something wrong with project structure.
  • 1
    @Root negatron, I can do with php everything web and I have yet to be hurt by the "inherently broken" aspect of it, which was dropped on version 5, we on 8 now corazon, your dislike is misplaced.

    But Ruby is still the most beautiful programming language
  • 0
    @theabbie There was no project structure, that's the point. I was trying to structuralise it by abstracting bits and putting in separate files, then I wanted to put some of those files in directories and looked for 4 hours on how to do it only to find out there's no good way.
Add Comment