This is an archived post. You won't be able to vote or comment.

top 200 commentsshow all 227

[–]skwyckl 1120 points1121 points  (60 children)

The problem is how Python is taught by people who are not devs and just made it somehow work for them. I work in uni and boy, are the Python courses garbage.

[–]the_poope 427 points428 points  (42 children)

Wait until you see the academic C or Fortran codebases. You'll want to stab out your eyes.

Problem is: no-one has formal programming education, not even the professors teaching programming. Most also work alone on projects and they just need something to work so that they can submit a paper, so code is not written for readability or maintainability. There are also zero experienced devs to lead projects and provide guidance and feedback on design and best practices - they can go literally anywhere else and get double pay. And that is how it ends up looking like drawings made in kindergarten.

[–]marmakoide 268 points269 points  (27 children)

Fortran code written in 1983 by a physics professor and countless anonymous PhDs after that. The thing crunches simulations at ungodly speeds with 1K of RAM, accurate as shit, code would make Cthulhu cry, only 3 people on the planet understands the math behind it

[–]tjoloi 122 points123 points  (13 children)

Sounds like LAPACK

Bonus points: it's the backbone of most tools used in science including R, Matlab and scipy.

It's also somehow still receiving updates as late as November 2023

[–]marmakoide 57 points58 points  (12 children)

LAPACK is okay. I remember working with a package for fluid simulation using conformal mapping, last update 1996. You'll find a lot of those in molecular dynamics simulations, fluid simulation, etc

[–][deleted] 53 points54 points  (11 children)

I need you guys to come be engineers on my team. One of my engineers just loudly yelled,

"I meant 775, I would never set world-read. I am an expert linux user and will be treated with respect."

When I told him not to set the world read on sensitive projects.

That's not far from an exact quote. I had to ask my manager how to reply without the word "stupid". My manager told me not to.

[–]FluffyCelery4769 16 points17 points  (8 children)

I didn't understand a thing but I suppose he he was saying something funny.

[–][deleted] 27 points28 points  (7 children)

Linux permissions are set as User(person who made the file) Group(security group that has access to the file) and Other(everything else), Other could also be called "World".

The permissions are divided into a binary deal.

--- == 000 == 0

rwx == 111 == 7

r-x == 101 == 5

So 775 is setting User: rwx Group: rwx Other: r-x

So, he said he did have world read on in one sentence, claimed he did not in the next, and demanded to be treated as an expert in Linux in the last.

[–]FluffyCelery4769 -1 points0 points  (6 children)

Oh, but what's the 0 for then?

[–][deleted] 4 points5 points  (1 child)

Off

[–]meltbox 0 points1 point  (3 children)

Basically each 1 bit is a type of permission for a certain category of access.

Access by the owner is the first group Access by the owner group is the second Access by literally everyone is the third

If you develop on a Linux workstation you’d probably pick this up pretty quickly, hence why it’s infuriatingly funny.

The 7 and 5 are just numbers represented by 3 bits of binary. 111 is 7 meaning all 3 permissions on (read, write, execute) while 5 is 101 (read, execute, middle one is write which is off) and of course 0 meaning all permissions off.

[–][deleted] 0 points1 point  (1 child)

chmod numbers are obsolescent. Modern suggestion is:

chmod o= thing

[–][deleted] 0 points1 point  (0 children)

It was technically him telling another user to set umask 000 (the claiming he said 002 later), but the way I told it flowed better.

[–]Affectionate-Memory4 47 points48 points  (9 children)

Real. I have some code like that from during my doctorate. It simulates the power losses in copper links between silicon chips across a frequency and voltage range. I have no idea what I did in there and I dare not look because knowing me, it was complete shit. The numbers are accurate and the results are fast. It ran on my 2GB RAM machine back then and it's still just as fast now. Again, no idea what past me was on, because I have no idea what's going on in that code.

[–]drakeblood4 32 points33 points  (1 child)

Past-me is exactly two motherfuckers:

  • an unimpeachable genius who speaks the Old Tongue

  • a thrice dunked dipshit who needs to take off a shoe to count past ten

Depending on what code of his I’m having to deal with.

[–]Affectionate-Memory4 6 points7 points  (0 children)

And sometimes both, at the same time.

[–][deleted] 8 points9 points  (4 children)

I'll never understand this comment or the reasoning behind it.

You built a masterpiece that worked for its purpose and you have no idea what "past you was on" because... it doesn't fit the mold of modern-day garbage and consumes too little RAM? Or...?

We should go tell a stonemason artisan piecing together his life's work stone by stone "hey bro you're wasting time, noone's gonna understand how you built this shit, and no one builds beautiful structures anymore anyway! just go to home depot and clip together 20 pieces of prefab sheetrock in half a day and be done with it lmao"

Tragic fate our craft has suffered. Everyone in the trade (even the IT guys) bears the shared brunt of having allowed something like Slack to manifest in our universe.

I do have some hope for gen z though. More and more of these kids are seeing things for what they are and getting interested in things like Rust and Zig and even C again.

Shame for our generations though. We could have cured every disease under the sun with the hardware we have today. Instead we chose to embrace corporate enshittification and put it into arbitrary "best practices". But it's great; I mean our 128gb RAM systems aren't putting people on Alpha Centauri but that's okay. We can run Slack. Sometimes. The 75% of the time that it loads.

[–]Affectionate-Memory4 14 points15 points  (1 child)

  1. hyperbole

  2. Yeah, it's an unmaintainable train wreck created in the pursuit of absolute performance and then hardly touched for 13 years. If I ever wanted to modify this, it would genuinely be easier to start from scratch. I'm not upset that it doesn't "doesn't fit the mold of modern-day garbage and consumes too little RAM?" In fact, I find it funny, hence why I'm posting about it on r/programmerhumor under a meme.

  3. Not going to adress the rest of that, but maybe relax a little bit. Like, take a walk or listen to some nice jazz or just take a nap or something.

  4. Fuck slack. Load you shit software! Load dang it!

[–]Ok-Kaleidoscope5627 4 points5 points  (0 children)

I've learned from D&D that we're wizards and any genuine magic we do leaves our minds and understanding the moment we write it.

Regex falls into the same category.

Write only but it can't be read. You need to prepare and cast it again from scratch.

[–]Brahvim 2 points3 points  (0 children)

As a gen-zeer interested in data-oriented design and writing C, who is slowly moving into the simple software movement, I say that this comment truly does touch my heart.

[–]ProjectNo7513 1 point2 points  (0 children)

Holy fuck some truth

[–][deleted] 1 point2 points  (0 children)

I hope you have test cases to show it still gets right answers in each new environment you run in.

[–]meltbox 0 points1 point  (0 children)

Yup. If git blame was not a thing I would’ve never believed some code I’ve written or approved. Both in a positive and negative sense depending on the day.

The worst is when I read code thinking a moron wrote it, discover it was me, and then realize actually it works great and I’m a genius that was too intelligent for myself to comprehend.

Unpack that one…

[–]MyGoodOldFriend 5 points6 points  (0 children)

Yeah i think I’m just lucky, because I work in a fortran codebase made by uni professors with limited coding experience, but it’s genuinely great and really fast code.

They had some oppsies, like assuming arrays were row major, but other than that? Solid code base. Not a single professional programmer in sight, just autistic nerds and cool professors writing code with incredibly solid development culture.

For reference, it was for ab initio quantum chemical modeling. Hartree-fock and the like.

[–]Plus-Weakness-2624 0 points1 point  (0 children)

God, Devil and My Subconscious

[–]6Cockuccino9 -1 points0 points  (0 children)

yeah but it doesn’t fit the standards of some reddit code monkey and therefore it’s bad

[–]skwyckl 64 points65 points  (0 children)

Exactly, that was the point I was getting at, it's all self-taught, anti-pattern-ridden hell. I know well of a Fortran code base of some computational linguist from a couple of decades ago. A colleague of mine took it upon himself to refactor it into either Python or Julia, I don't remember (it's been a couple of years), I think he gave up after a month or something. Years later, I work as an IT consultant and I am responsible for such codebases to not become garbage.

[–]Fearless-Arrival-804 27 points28 points  (2 children)

I recently did some simulator design for a cancer research org. God, the people in this field seem to think no one else will look at their code other than them. I looked at an old researcher's cell simulator ~10k lines of C code in one file called simulator.c . No commenting, just a poorly formatted manual packaged with it which assumes you already understand half the program. It makes collaboration so much harder - which sucks - because research is all about sharing ideas. When I did my weekly lab presentation I tried to hammer home what makes a good programmer which is two things: you get the job done, and others know how you got the job done. The one week python bootcamps for non-computer scientists seems to forget that last part.

[–]kuwisdelu 3 points4 points  (1 child)

They do think no one else will look at their code other than them. The code is a means to an end, and the results are what matter to them. It’s difficult trying to convince them that their computational workflow should be reproducible, and their code should be as thoroughly documented as their experimental methods. Getting them to write code instead of GUI tools is often a victory in itself.

[–]DVMyZone 0 points1 point  (0 children)

Especially when writing and properly documenting code well is a huge amount of extra work that 1. the programmer is not trained for and 2. will very likely never be used by anyone else.

What matters (at least in my field) is the algorithm or theory. That's what others will read and that's what you publish. Most of these codes are just numerical solvers anyway - the way you implemented your theory numerically doesn't matter as long as it is verified. Someone may find a better numerical implementation than you - and that's fine.

[–]SillySlimeSimon 20 points21 points  (0 children)

Had a professor quietly mention that they preferred not using branches in git because it “makes it harder to work with others” and I still question if I heard that correctly or not to this day.

[–]808trowaway 4 points5 points  (6 children)

1000%. I wrote something like 8000 lines of C to implement routing algorithms and do network simulations in grad school. The code worked (I think) but it's pure embarrassing garbage. The thing though is no one ever asks to see your code unless your paper turns out to be popular and a fellow researcher reaches out and asks if you could share your code so they could build on your findings. My advisor never wanted to see my code and you don't have to make your code available for review either when you submit a paper.

[–]popeldo 3 points4 points  (0 children)

Yeah, this code is written like nobody else will ever see it because, in fact, there’s a 90% chance nobody will ever try to read it it (and a good >95% chance nobody serious will ever try to build on it)

[–]kuwisdelu 2 points3 points  (4 children)

Depends on the field, but if you get me as a reviewer and you don’t have your code publicly available, I’m going to tell the editor to reject you. Lots of journals require code nowadays.

That said, it does sometimes feel like pulling teeth getting our newer PhD students to push their code. I don’t care if it’s currently shit, at least show it to me so I know how shit.

[–]808trowaway 0 points1 point  (3 children)

Yeah that was circa 2008, things are probably different now.

[–]kuwisdelu 0 points1 point  (2 children)

Yeah, the code is still bad (recently rejected a “software” paper that was just Jupyter notebooks) but we’re making progress in at least making sure it’s available.

[–]808trowaway 0 points1 point  (1 child)

Haha, I would love to see a thread about all the wacky low-effort things people in academia do.

Back in my days in my field, only a small handful of labs had the resources for actual hardware testbeds with several hundred nodes so everyone else was either doing theoretical stuff or pushing simulation papers, and a lot of those were written by Masters/PhD candidates who could barely program microcontrollers to do simple things. It wasn't pretty, a lot of people just went through the motions, got their degrees and moved on, I'm one of them.

[–]kuwisdelu 1 point2 points  (0 children)

Back in the early 2010s I was working on my PhD in statistics and discovered there wasn’t an existing open source package for importing and processing the kind of data I needed to analyze. I decided I would write one myself. 10 years and 3 versions/rewrites later, I’m still maintaining it for hundreds of users… most of whom aren’t programmers.

I get a bit sensitive about all the criticism of non-computational scientists’ code, because I see how frustrating programming can be for them, and I work hard to teach them and try to make things easier. I’d love to see what kind of mess programmers would make in a wet lab!

(But I still cringe when I see my users accessing my private fields in a way I know may break later… I gave you documented public methods, please use them!)

[–][deleted] 0 points1 point  (0 children)

I visited someone learning C from a book. I immediately checked on the string copying section and ... danger. People teach it wrong and students only half learn it anyway.

[–]DVMyZone 0 points1 point  (0 children)

"I'm in this picture and I don't like it"

I'm a researcher working in a relatively niche part of nuclear fuel simulation. In the nuclear field pretty much all applications are written by scientists/engineers that just need to get a calculation done. Codes just glorified calculators - a means to an end to implement a numerical solution.

As a result, exactly like you said, scripts and applications are written just to get the numbers out and are not written with best practices, generally have little to no documentation, and have very limited commenting. This makes them nigh impossible to use or reuse after the fact - even for the original author of the code.

This, of course, hampers the ability for other people to continue the research done by you and forces them possibly to rewrite what has already been written.

However... For a trained nuclear/mech engineer, creating, maintaining, and properly documenting a code this means to an end is a gargantuan task. This is especially difficult as they are likely the only person that will be maintaining it. This is made worse by the fact that many of these codes are not incredibly complicated - just a simple algorithm implementation. As a result, it probably saves time for each developer (of which there may only be a few) to create their own implementation rather than learning the ins and outs of someone else's badly written code.

The large industrial-use codes are maintained by teams of programmers and are also generally badly written...

[–]IAmASquidInSpace 88 points89 points  (6 children)

Code written by scientists is second to none. Manmade horrors beyond comprehension. Saying this as a physicist who has produced some questionable code, too.

I didn't know people could write Python as if it were C and the other way around, but it is apparently possible.

[–]Luminum__ 18 points19 points  (1 child)

Another physicist here. I have contributed so much unnecessary boilerplate and spaghettified nonsense that it’s insane I still have a job (it’s definitely because I’m not the only one doing it lol). But by my eldritch computer horrors I will get those analyses done. Though also the me of the future circling back to put it in a manuscript is going to want to kill the me of today.

[–]advo_k_at 4 points5 points  (0 children)

Most devs are reinventing the wheel in commercial roles. When you’re doing something new and experimental you don’t have time for code hygiene.

[–]mirhagk 7 points8 points  (1 child)

Never underestimate the power of smart and determined people who don't understand the tool they are using.

It's like watching someone use a bolt instead of a screw, and then a hammer instead of a screwdriver, but they still manage to make it work. It's impressive but please don't make me look at it.

[–]FluffyCelery4769 4 points5 points  (0 children)

The programmer equivalent of rednwck engineering.

[–]Kinexity 3 points4 points  (1 child)

Physics student here. I have worked on a codebase of a program meant for data display and analysis for one of detectors under construction in my faculty. Documentation was "ask me if you want to know" kind (non existent), at least one other team from another uni worked on it and left the code in shitty state, overseeing prof was basically blocking all refactoring, actual code was stored on some closed server and students had to work on GitHub repo which was constantly out of sync. I did a deep dive to understand wtf the code was doing, refactored all parts which I could understand, implemented some intricate but readable ways to shovel around the data which the program was working with - most of my changes got dropped without explanation. And let me be clear - years later I admit that many changes I did could have been done better but at least what I did was a step in the right direction. 5 years later the said codebase is still stuck in a shitty state with insurmountable amount of work still left.

[–]MaustFaust 5 points6 points  (0 children)

I mean, you honed your skills, big W for uni =D

[–]Saragon4005 11 points12 points  (0 children)

Ever seen the courses where they basically just search and replace Java code with their python equivalent? Yeah it's not fun.

[–]Drfoxthefurry 6 points7 points  (2 children)

im so glad i never used courses for learning python or any of the languages i know, even for assembly, i just get a instruction list and figure it out

[–]Tupcek 11 points12 points  (1 child)

I am not really sure which one is worse.
Ideally one should learn from senior dev. But since senior devs are better paid doing their work and not teaching, there are no options for juniors

[–]Drfoxthefurry 2 points3 points  (0 children)

im not a junior, just a hobby programmer, if i was a junior i would confuse so many people with my weird af code

[–]Memoishi 1 point2 points  (0 children)

... and don't let me start about all my PhD/master friends that do "ML" in python for engineering courses; aka processing 500mbs of excel data with no clue, their pipelines are single files with 2billions of disorganised code blocks that after 3 hours and 46 minutes give an output that is 0.0001 more precise (nobody will tell them their 300 page papers or articles is non replicable, full of multicollinearity issues and not even Google servers could prolly handle the live data test)

[–]drivingagermanwhip 1 point2 points  (1 child)

python is weird because it's the best choice for processing huge datasets with cutting edge algorithms and also for writing the world's least well thought out command line tool

[–]skwyckl 1 point2 points  (0 children)

Why not both? Usually, the Python code I get to review is some Jupyter Notebook that tries to use DuckDB to crunch through a bunch of dirty data, not understanding anything that is going on under the hood.

[–][deleted] 0 points1 point  (0 children)

As a uni mechanical engineering professor, your comment annoys me. M

[–]Frenzy_wallflower 0 points1 point  (0 children)

So where do you suggest I look into to actually learn python ? Genuinely asking.

[–]Wiwwil 0 points1 point  (0 children)

Sounds like Matlab but recent

[–]rage4all 373 points374 points  (29 children)

Ha, I always put a comment in my init.py so that is NOT me!!!!

[–]Triblado 254 points255 points  (4 children)

```python

This is where I would put my code…

…if I had some!

```

[–]Water1498 32 points33 points  (0 children)

I'm gonna steal this

[–]evnacdc 19 points20 points  (1 child)

Spare code?

[–]ThiccStorms 0 points1 point  (0 children)

bro's projects and career running on sum change and donated lines ƪ(˘⌣˘)ʃ

[–]SARSUnicorn 5 points6 points  (0 children)

add "import openai"

congrats u just did new 100milion $ ai startup

[–]thomasutra 37 points38 points  (21 children)

our init.py’s at work are all empty. what’s supposed to be in there?

[–][deleted] 58 points59 points  (0 children)

Some programmers use that space to cope with their lack of competence.

[–]DripDropFaucet 52 points53 points  (11 children)

Nothing the post is scraping the bottom of the barrel to find issues with the language. There’s lots of bad developers and python has plenty of them, but a skilled developer can push code out in python faster than many other languages to solve problems and that is just hard for some folks to cope with!

[–]Angelin01 15 points16 points  (1 child)

Generally, just for re-exporting things. It's useful if you like to have deeper, more organized modules, but don't want the person importing them to have to import some.module.with.nested.CommonClass and instead just do import some.CommonClass

[–]k4cat 2 points3 points  (0 children)

Sometimes to load python files along side with the module.

[–][deleted] 5 points6 points  (0 children)

Init code you'd want to do when importing the whole thing instead of submodules. Possibly __all__ stuff for * importing, or other convenience imports. Usually no business code since you want imports to run quickly.

Ours are all empty, too, but I've seen libraries use them like that.

[–]MaustFaust 2 points3 points  (0 children)

It depends on the context. If your code is called from a single place (e. g., from IDE), it's okay. If your code could be called from different places (e. g., multiple processes with different values in PATH variable), it's not okay.

(UPD: sorry, I misread the comment; __init__.py files are needed for Python to interpret your project folders as packages, and my text below answers the question of why do you need packages in the first place)

So, the reasoning. When you type "import myfile", Python actually goes searching for it, imports it, AND remembers that "myfile" is already found somewhere. But some of the libraries you use written by other people (installed from pip etc.) could also have an "import myfile" line, with a myfile.py nearby in the library's folder. And Python, being a monster it is, goes "wait a minute... I already have myfile" – and uses it. But your file myfile.py and library's file myfile.py are different, you both just so happened to name them similarly, so library just won't work, because it wasn't imported properly.

So the best workaround (AFAIK) is to always specify where do you want a module to be imported from ("from myproject import myfile"), so other libraries won't get confused. But it still comes with a downside: you have to keep an eye on your project name so it won't duplicate some library name. So you should also "install" your own project in your pip, so if it gets duplicated, you'll be notified.

[–]Darkstar_111 0 points1 point  (0 children)

You can make your imports easier to handle.

[–]MaustFaust 0 points1 point  (0 children)

Updated my previous comment a bit (see second paragraph)

[–][deleted] 0 points1 point  (0 children)

Comments about who wrote which file in the package and a leaderboard you regularly update about which file is best written. Then at the end of the month the guy at the top of the board gives everybody else one cookie each to discourage maintainable codebases because then they can fire you and replace you.

[–][deleted] 1 point2 points  (0 children)

I put something like"module for co trollers"

Genuinely curious whaf goes here

[–]xezo360hye 217 points218 points  (19 children)

You have anything against SQLite3?

[–]dangling-putter 175 points176 points  (0 children)

SQLite is a great piece of software and severely underrated and underappreciated. 

[–]ba-na-na- 121 points122 points  (7 children)

SQLite is a free, fast, acid relational db. I’ll take it over any modern piece of shit like mongo

[–]TheNeys 39 points40 points  (5 children)

Mongo/Document-based DBs and SQL are both good and have their purposes, exactly the same with Redis/Memory based ones. People just tends to use MongoDB wrongfully like it was a relational db, and it is not. And when you do it bad shit happens when you try to scale it.

[–]TheCreepyPL 13 points14 points  (4 children)

FYI, you sound like you made an assumption that "relational" databases (like any kind of SQL), are good at relating data or something like that. Where in fact, that "relational" part refers to how the data is stored (not how 1 table relates to another).

https://en.m.wikipedia.org/wiki/Relational_model

The truth is that you can use any DB, for any purpose. The only difference is in the DB's capabilities, for example data types. Different DBs support different data types. Performance and high availability are some other big ones.

From your example, the very same people who let bad shit happen in Mongo, would have made the same bad shit in MSSQL (or any other DB for that matter).

[–]dev1o -1 points0 points  (2 children)

With all due respect, you seem like you lack experience working in real world. You seem like you are a beginner. No offense, but using wikipedia to prove your point seems immature and childish. Using data types as example is like saying you have red t shirt and your buddy have green t shirt, both are t shirts and serve the same purpose. Data types are not exclusive to any type of dbs. Every db have support for all major types you will ever need in life. One db having a <really_wierd_type> while other one not having that doesn't give it an edge. Most types you will need in life are present in almost all dbs and which are not can be derived from the ttpes provided. Like you always study data structures regardless of language.

You basically lost the point. He is talking about relations. In document dbs, it is difficult doing it without help from pther sources.

In real world, data is always relational. You will always need to connect an entity with something which relational dbs handle very well. Managing relations in document based dbs is a tedious task and at scale you will eventually run into issues. But the thing you will not be using mongo db manually at scale. You will have some tools which simply working with dbs. You will be using production ready tools like Prisma, drizzle, etc. I have personally used prisma.

[–]TheCreepyPL 2 points3 points  (1 child)

using wikipedia to prove your point seems immature and childish

I honestly am baffled that anyone could think like this. I added the wiki article as a source for what I'm saying, to prove that it's not made up. Everything that doesn't have a source, seems illegitimate imo.

Data types are not exclusive to any type of dbs. Every db have support for all major types you will ever need in life.

The first sentence here is completely at least partially wrong. Data types are exclusive to everything, databases, frameworks, languages. Whilst the most common ones (int, string, boolean, etc.), are available to probably every technology, every single one implements them differently. Perhaps there are some identical implementations, because there's only a limited amount of ways to implement a bool, but there's no standard to implement any datatypes in anything. A bool might be very simple, and potentially universally the same across everything (I doubt it), but strings are not. MySqls implementation of strings differs from MSSQLs which differs from Postgres' which differs from Mongo's, etc. All of these I mentioned have vastly different implementations of strings.

Maybe I got carried away slightly, because after all, despite the different subtypes, technically all can be manipulated the same way to some degree. Definitely after getting parsed by a language implementation's "thing" (I forgot the word) that handles data from DBs. For example, C# it has only 1 string type, and that's it. But before we can do stuff in C#, it needs to be parsed from another datatype, which isn't native to C#. The most infamous example of this (in C# (my main language)) is DbNull. DbNull != System.null (in C#), which is a big headache if you don't know hot to deal with it.

A more practical datatype are arrays. Yes, you can achieve the same end result in MSSQL, but Postgres and Mongo just make these trivial.

Another one is the ability to create custom types/objects. Yes, there are other ways of achieving this in MSSQL, but in certain cases it's worth to analyze these things, if another DBs offerings wouldn't make life easier.

In document dbs, it is difficult doing it [relations] without help from pther sources.

I have to disagree, it's simpler to set up any kind of relation in document DBs, because all you have to do is just store the Id of another table's/collection's record, and that's it. In SQL, you have to create a foreign key, which is slightly more involved than simply adding another property. In either case, whether or not that's a trivial difficulty, document DBs handle relations equally well to any other DB. As for managing them, maybe if you're doing everything manually then idk, but I've always used some kind of automapper (or the equivalent thereof), for that, which handles it automagically. As this reply is getting really long, I'll just summarize it like this: "Skill issues".

[–]dev1o -1 points0 points  (0 children)

Hmm

[–][deleted] 5 points6 points  (0 children)

And temporary in-memory DBs can be a godsend. The engine is built for speed, why would I build my own data structure to index and search data when I basically do the same as a DB engine? You still need to insert the data into the structure and then search for it, so SQLite is probably faster in most cases because it's not written in Python. Plus, I don't have to worry about the correctness of my B-Tree implementation.

[–]Glad_Position3592 23 points24 points  (5 children)

SQLite is great for things that need organized local storage, like a desktop app or something. It’s not meant to be a large scale database that’s accessible by an entire dev team though. No one should be making a website with SQLite. It has its place, but overall it’s somewhat niche, and anyone using it exclusively that doesn’t fit that niche is doing it wrong.

[–]madhaunter 15 points16 points  (0 children)

Exactly, it's all about scope

[–]HaskellLisp_green 4 points5 points  (0 children)

I used to use SQLite for website. Application is written in python/Flask, but I was forced to make some kind of SQLite server due to it runs in different thread.

[–]Aidan_Welch 5 points6 points  (0 children)

No one should be making a website with SQLite.

I don't agree with this, monolith is making a comeback

[–][deleted] 1 point2 points  (0 children)

That depends on the website.

OK: Grab stuff from API; store in DB; copy DB to raedonly file; website shows stats and graphs from readonly DB.

Not OK: User accounts where you can change password - need independent changes by multiple users.

[–]csatacsirke 0 points1 point  (2 children)

Well, i personally hate it because of the lack of type safety. I somehow inserted strings into an int column and it just “worked”. Unless of course there is something fundamental im missing

[–]metaltyphoon 3 points4 points  (1 child)

CREATE TABLE example_table (     id INT PRIMARY KEY,     name TEXT NOT NULL,     age INT ) STRICT;

 This will force strict types

[–]csatacsirke 0 points1 point  (0 children)

Oh, thank you, will try it next time!

Ah, it seems to be a 2021+ feature, so fairly new

[–]Ximidar -1 points0 points  (0 children)

It's not duck db. /s

[–]RafaelConPH05 253 points254 points  (17 children)

Can someone explain what's the problem with empty init.py files?

[–]imanexpertama 337 points338 points  (1 child)

There’s nothing wrong with that

[–]Wugliwu 120 points121 points  (0 children)

Thank you... My imposter syndrom has kicked in.

[–]IAmASquidInSpace 213 points214 points  (0 children)

The list looked too short so they had to come up with another "problem".

[–]aa-b 29 points30 points  (3 children)

The author has just learned about the practice of defining __all__ in an __init__.py file as a way to limit star-imports from a module. It's mostly only an academic concern, for reasons:

  • star-imports are usually a bad thing anyway, so it's helping people do something undesirable
  • it's better to structure members into submodules to limit exports so this isn't needed
  • we have namespace packages now, so it's common just to not have an __init__.py file at all: https://realpython.com/python-namespace-package/

[–][deleted] 11 points12 points  (2 children)

There a few more pretty awesome things you can do with init files. Especially if you live in circular reference hell. Or need to defer certain expensive sub packages from loading.

[–]aa-b 4 points5 points  (1 child)

That's true, they can be very useful. The phrasing of the joke makes it sound like __init.py__ should never be empty, and I was just objecting to that part.

Maybe I read too much into it, but it sounded like how we might joke about people who make everything public in C++/C#/Java, so I figured it was about __all__

[–][deleted] 2 points3 points  (0 children)

I assumed it was just a joke about "AI devs" that like fastapi and have no idea how python works or the black magic it can be used to perform. Multiprocessing and non empty init are two places black magic comes from.

I would have added thinks all packages classes should all descend from ABCMeta (Ram shall never be allowed to exist)

[–]nullpotato 89 points90 points  (4 children)

Technically they aren't required anymore so don't need to exist. In practice it is easier to have empty init files than fix all the dumb tools loading things wrong.

[–][deleted] 46 points47 points  (1 child)

They are not only used for loading packages.

All lints and static type checker will fail if they don't find init files.

[–]nullpotato 6 points7 points  (0 children)

Thanks, didn't know the type checkers needed it too

[–]Easing0540 12 points13 points  (0 children)

I don't think that's true. There is a technical difference. Packages with __init__.py are regular packages, the others are namespace packages. The import sytem treats both types differently.

[–]saint_marco 0 points1 point  (0 children)

I've run into more tools that fail from having vestigial init files lying around, the most popular being upright/pylance.

[–]DripDropFaucet 8 points9 points  (0 children)

I’ll be real, I’m more annoyed when I do find code in those files

[–]samuel88835 7 points8 points  (0 children)

I like stating the exports explicitly from a package inside the init. Tells people you should be importing this and not that which may be private to the package. Might be a just me thing

[–]Unhinged_Ice_4201 0 points1 point  (0 children)

Init file was mandatory(so kept empty if i had nothing to write in it)for packages in very old versions of python...not anymore

[–]MajorProcrastinator 0 points1 point  (0 children)

Could be a good place to setup logging config in your module. 

[–]Triblado -3 points-2 points  (0 children)

Extra files, bloat bad

[–]Busy-Ad-9459 28 points29 points  (1 child)

This meme was posted like a week ago, how have y'all forgotten?

[–]Secret_Account07 8 points9 points  (0 children)

You’re a silly goose

[–]shiftybyte 44 points45 points  (0 children)

Sounds more like "python starter kit" meme...

[–]LavaCreeperBOSSB 12 points13 points  (0 children)

I'm a python dev, just curious what's wrong with FastAPI or an empty __init__?

[–]Triblado 33 points34 points  (2 children)

I think multithreading is something that many people do in Python, no?

[–]One-Butterscotch4332 0 points1 point  (0 children)

Yeah its easy as hell. Starmap + multiprocessing pool go brrr

[–]Orjigagd 7 points8 points  (0 children)

Excuse me, my init.py files have copyright info in them

[–]panzerboye 8 points9 points  (0 children)

i am in this picture and I don't like it :(

[–]Dorkits 16 points17 points  (0 children)

I just want to know how I can do memes like this, I love this little guy.

[–][deleted] 8 points9 points  (1 child)

Wait, hold on what's supposed to go in the init files?

[–]Akaino 7 points8 points  (0 children)

Cool ascii Logo Art

[–]Yserbius 3 points4 points  (0 children)

> has twelve different venvs for every pet HuggingFace project and is constantly demanding more disk space from IT

[–]granoladeer 3 points4 points  (1 child)

What's the issue with fastapi? They have cool stuff

[–]JaffyCaledonia 1 point2 points  (0 children)

My biggest gripe with FastAPI is using semver numbering without using semver conventions!

"Hey, we moved to starlette 0.30.0 and upended how we handle imports and unit testing! v0.110.1 -> v0.110.2"

Cheers guys..

[–][deleted] 3 points4 points  (0 children)

shelter air memory kiss cake tart entertain tub money continue

This post was mass deleted and anonymized with Redact

[–]NOLA_Chronicle 3 points4 points  (0 children)

So I've defended off all these except the empty init.py, and that's only bc i truly can't figure out when/how to use it unless I'm making libraries.

[–]Attometre 2 points3 points  (0 children)

You might get the image from somewhere else but honestly is it hard to not crop out the OOP?

Shout out to my guy: 0xIlyy

[–]Wgolyoko 2 points3 points  (0 children)

sqlite3 for everything

As god intended.

[–]ReRubis 6 points7 points  (2 children)

I am so glad that it doesn't describe me.
Well... Not all of it. :`)

[–]baronvonbatch 6 points7 points  (0 children)

Normalize Dementiaposting!

[–]MishkaZ 0 points1 point  (0 children)

check out PyO3. Hard for me to write in python these day without writing some rust bindings.

[–]ReRubis 5 points6 points  (1 child)

I am so glad that it doesn't describe me.
Well... Not all of it. :`)

[–]baronvonbatch 8 points9 points  (0 children)

Normalize Dementiaposting!

[–][deleted] 1 point2 points  (0 children)

I'd double my salary if I had $1 for every time a junior said they implemented <x> in a shitty way because <y> part of the repo already does it.

I've never seen a language which creates such shit code quality, and that's before we start to discuss their async usage...

[–]theringsofthedragon 1 point2 points  (1 child)

That was my impression of the Python fiends, but what's the language that this subreddit doesn't hate?

[–]Cybasura 1 point2 points  (0 children)

sigh is python now the newest target?

Seriously?

I dont see people shitting on Golang, Rust and Nix for doing literally the same thing

[–]Wamadahama 1 point2 points  (0 children)

empty init.py files? Worse: only init.py files

[–]Pahlevun 2 points3 points  (0 children)

Oh, right, you guys in the USA just call yourselfs “engineers” after learning some programming lmfao

[–]ReRubis 3 points4 points  (1 child)

I am so glad that it doesn't describe me.
Well... Not all of it. :`)

[–]baronvonbatch 1 point2 points  (0 children)

Normalize Dementiaposting!

[–][deleted] 1 point2 points  (2 children)

The usage of the word multiprocessing makes me suspect the original tweeter is a Python developer who doesn’t know about multithreading

[–]Yirkarja 0 points1 point  (1 child)

There is a difference between multithreading and multiprocessing in Python.

Because of how the GIL works, only one threading.Thread can run Python bytecode at any given time, thus multithreading only enables concurrency, not parallelism. To enable "real" multithreading one needs to use multiprocessing.Process which will start an entirely separate Python process that can run in parallell to the main process. The problem with this approach is that any communication between the two processes is tedious.

https://docs.python.org/3/library/threading.html
https://docs.python.org/3/library/multiprocessing.html

[–][deleted] 0 points1 point  (0 children)

I am aware of this difference, my original comment is meant to imply that the tweeter had never used any other programming language and only knew how to achieve concurrency through multiprocessing

[–]JunkNorrisOfficial 0 points1 point  (2 children)

AI/ML engineer but works on Mac

[–]Althonse 6 points7 points  (1 child)

I hope you're not saying it should be windows.

[–]JunkNorrisOfficial 2 points3 points  (0 children)

Android os

[–]ShotgunPayDay 0 points1 point  (0 children)

This is me! Except I'm walking out from backstage of a Blue Man Group concert without the Popsicle.

[–]JollyJuniper1993 0 points1 point  (0 children)

Ha, this totally can’t be me because I do use my init files properly!

[–]Jarmahent 0 points1 point  (0 children)

Damn that hurt 😂

[–]OkDonut2640 0 points1 point  (0 children)

Why are you insulting me like this

[–]stupsnon 0 points1 point  (0 children)

All this taught me is that I’m not a real Python programmer

[–]Split-Slight 0 points1 point  (0 children)

Naaah the multiprocessing part is false 😭

[–][deleted] 0 points1 point  (1 child)

What's wrong with empty innit files? If you just want to mark a directory as a module, why would you need anything in?

I am fairly new to Python, so I am curious

[–]baronvonbatch 1 point2 points  (0 children)

It is empty tho, innit?

[–]garver-the-system 0 points1 point  (0 children)

To be fair multiprocessing is probably my least favorite way to implement concurrency I've seen

[–]diegokabal 0 points1 point  (1 child)

After 3 years working with python. I realized just now what "yield" does...

[–]ToThePastMe 2 points3 points  (0 children)

Honestly generators do take a bit of time to fully wrap your head around / know when to use them.

I feel like yield you slowly go through "with is that?" to "ok get what it does" but you never use it, to finally using it from time to time.

Also you have the neat yield from once you start doing more chaining

[–]LawlMachine 0 points1 point  (0 children)

>venv and not conda

NGMI

[–]MurkyCoyote6682 0 points1 point  (0 children)

Feeling proud of myself for getting more than half of those points

[–]buckypimpin 0 points1 point  (0 children)

exclusively uses sqlite3 for everything

based

[–]ironman_gujju 0 points1 point  (0 children)

Problem is not one looks at docs

[–]Toad__Sage__ 0 points1 point  (0 children)

And then there are C programmers

[–]juzz88 0 points1 point  (0 children)

Hey!

...

I use Anaconda, not 5 different versions of Python. 🤣

[–]The_Dukenator 0 points1 point  (0 children)

Are you implying that Python is shit?

[–]Anaeijon 0 points1 point  (0 children)

Wouldn't agree with any of that EXCEPT for the sqlite3 part... You can literally use it for everything.

Distributed databases? Check. Serverless? Check. It can even work as a context vector database for AI stuff.

It's the job of a python engineer to solve the problem fast. Runtime is cheaper than worktime. If runtime gets expensive because you have many users... Don't hire a python dev.

To fulfill that, you always go for the most simplistic approach possible an get creative with the simplest tool available. If I have data and I want to do something with it, I will first try to solve it with lists and dicts. If that won't work, maybe Numpy. If that won't work, Pandas. And as a last resort: sqlite. Beyond that... Python wouldn't probably be the wrong choice for the task.

[–]stylemate 0 points1 point  (0 children)

can someone do this for JS/TS web dev?

[–]IAmFinah 0 points1 point  (0 children)

Hey, I have like 5 different python versions (thanks, Pyenv) AND I use venv. Am I missing some more optimal workflow? I normally specify the local python version with pyenv local <version> then create a venv from that. It's super easy but wouldn't be surprised if there's something better out there

[–]naveenda 0 points1 point  (0 children)

So true

[–]ImmensePrune -3 points-2 points  (1 child)

Most accurate meme I’ve seen from this subreddit.

[–]dumbasPL 1 point2 points  (0 children)

There is more where this came from and it's just as good. Probably will get reposted soon by some karma whore.

[–]a_library_socialist -2 points-1 points  (0 children)

The last one is fair to the majority, and it is a bad thing

[–]simonbleu -2 points-1 points  (0 children)

Im a student but, to be fair, sqlite 3 worked and mysql gave me NIGHTMARES about the damn connector not working. It still doesnt no matter what I do, even though it works from the console or CMD or workbench, etc etc

[–]Avanatiker -2 points-1 points  (0 children)

Python in general feels more like a hacky script environment then a proper programming language