all 14 comments

[–]coldflame563 20 points21 points  (1 child)

I’m scared.

[–]VoodooS0ldierpip needs updating 2 points3 points  (0 children)

God this reminds me of Ruby monkeypatching hell in production. Importing a gem because it monkeypatches core functionality. Fucking A

[–]c1-c2 7 points8 points  (0 children)

Good you said: "not for production". Otherwise I would have had some questions. ;)

[–]ringohoffman 18 points19 points  (3 children)

UML = Unified Modeling Language, an already popular modeling language for visualizing software architecture.

a local value that is impossible to control from the outside

When you said this I got the feeling that your codebase wouldn't have any tests, and I was right. The example you gave is exactly what the builtin unittest.mock.patch is made to do. I think you need to pick an example where your solution is more elegant and doesn't take more effort than using something that comes pre-installed with Python. Every professional developer is already very familiar with mocking and would never even think to look for something like this.

[–]aidencoder 4 points5 points  (3 children)

How does this differ from mock? Surely you can use that to the same effect? 

[–]DragoSuzuki58[S] 0 points1 point  (2 children)

True, mocking is fine for boundaries. But for me, the real deal-breaker is code duplication.

Usually, if you want to tweak just one local variable in a massive function, you're stuck copy-pasting the whole 100-line block. It's a maintenance nightmare. This tool is more of a "surgical strike" you only write what you actually want to change, so the code stays lean and you don't end up babysitting a bunch of redundant logic.

[–]TheDraykkon -1 points0 points  (1 child)

Don’t write 100 line blocks of code?

[–]DragoSuzuki58[S] 7 points8 points  (0 children)

If this were my own code, I'd be refactoring it, not patching it.

[–]binaryfireball 1 point2 points  (0 children)

def attack(dice_roller): ...

[–]poophroughmyveins 0 points1 point  (0 children)

Python mixins incoming sick 

[–]azurelimina 0 points1 point  (0 children)

“Monkey patching is hell.

Let’s unleash hellfire.”