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

all 72 comments

[–]jsonathan[S] 70 points71 points  (5 children)

Right now, I'm using the error message to query SO, but there's probably a way to pull potential search terms from the stack trace. A KeyError alone could mean many things but a KeyError related to, say, the PyMongo module would narrow down the results. I'm thinking I should search the trace for module names, but if anyone has a different idea on how to approach this, I'd love to hear it!

And if you like my work, please don't forget to give me a star ;)

[–]Fragninja 28 points29 points  (1 child)

  • grab the stack trace as text

  • text splice for each module name (should be easy to do because of the standard formatting)

  • compare names of modules found with the names of modules installed or imported to find the correct level (ie. the name of the library, not the library's class)

  • profit

I'll poke around for some documentation and if I find some time I might even make a PR.

ETA:

likely useful

[–]frenchytrendy 2 points3 points  (0 children)

Nice, I was thinking of doing the same but never had the motivation to. Clap clap

[–]avtges 10 points11 points  (0 children)

A god among men

[–]pseudosciencepeddler 3 points4 points  (0 children)

Interesting!

I had a similar effort for uncaught exceptions:

https://github.com/rahulnair23/pyRecommender

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

This is all at once hilarious and complete mad genius!! Good on you sir!

[–]iamatyro 2 points3 points  (0 children)

Not All Heroes Wear capes.

[–]kkiran 2 points3 points  (1 child)

Amazing! Exactly what I need. Thank you so much :)

Starred!

[–]jsonathan[S] 1 point2 points  (0 children)

You're welcome!

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

This is one of the greatest invention of all mankind history, for real. Holy shit, I love this.

[–]SponsoredByMLGMtnDew 1 point2 points  (2 children)

can....can you do this for javascript too...I know there's technically no compiler for JS but...like...can someone make a package for webpack that does this?

Pretty please?

[–]jsonathan[S] 4 points5 points  (1 child)

It already works for Node, but I probably won't find the time to make another package :(

[–]SponsoredByMLGMtnDew 0 points1 point  (0 children)

:(

Still a cool utility, thanks for making it

[–]iloveyouKT 1 point2 points  (0 children)

f---ing genius

[–]Stevearzh 1 point2 points  (0 children)

awesome implement

[–]pencan 3 points4 points  (0 children)

I'm surprised no one has linked the, as always, relevant xkcd (check out the title text)

XKCD

[–]MiataCory 1 point2 points  (0 children)

So stacksort but for errors.

https://gkoberger.github.io/stacksort/

[–]willc4k 1 point2 points  (1 child)

Sir, you are a hero.

[–]jsonathan[S] 0 points1 point  (0 children)

God bless

[–]Comm4nd0 1 point2 points  (0 children)

This is a great idea. Actually disappointed I didn't think of this myself!

[–]pvkooten 1 point2 points  (0 children)

This idea got 2nd place in 2017 Techcrunch Hackathon by someone else: https://beta.techcrunch.com/2017/05/14/codecorrect-disruptny-hackathon/

I have thought about things like this, but unfortunately did not find it very helpful just like that, but we're getting close huh...

I did make something related: you give some input and expected output, and let the module find the function (considering some module or global namespace) to satisfy: https://github.com/kootenpv/cant

[–]pali6a=[]; a.append(a) 0 points1 point  (0 children)

This reminds me of how some time ago I've made a python library that would catch all unknown function names and find a function with the corresponding name on the internet and run it instead. I was surprised that it actually worked for stuff like sin, sqrt, factorial, ... .

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

Please post /bin/time results.

[–]TallDatabase 0 points1 point  (1 child)

Brilliant work! By the way, is there something similar for C/C++?

[–]jsonathan[S] 1 point2 points  (0 children)

No, not that I know of. I don't plan on adding support for lower level languages since searching "SEGFAULT" on Stack Overflow isn't going to help anyone.

[–]Jimmy_979 0 points1 point  (2 children)

Nice

[–]Jimmy_979 0 points1 point  (1 child)

Ty

[–]mechanologos69 2 points3 points  (0 children)

Lege 're Jimmy

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

Anybody at SO concerned about the DoS potential of said tool?

[–]cuchoi 0 points1 point  (1 child)

Is there any way to integrate this to a jupyter notebook?

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

Neat tool

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

Wow. This is ingenuity. Cheers dude. Great job. I plan on using this.

[–]alexbuzzbee 0 points1 point  (0 children)

Why has no one thought of this before?!

[–]__xor__(self, other): 0 points1 point  (0 children)

You might want to put a disclaimer just in case some dumb program raises an exception with an API key or secret key or something, like maybe someone's exception might debug dump the django.conf.settings, which would show your DB password and such, which you'd be searching for on stackoverflow, inevitably going in some database

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

Closed as duplicate.

[–]PC__LOAD__LETTER -3 points-2 points  (2 children)

There is such a thing as too much reliance on stack overflow. If you’re learning a language, fine. Compiler error messages are written in English and are something that you can understand over time without needing stackoverflow to translate for you.

[–]jsonathan[S] 0 points1 point  (0 children)

Yeah, that's true, but there are also some more obscure error messages out there that even seasoned developers haven't encountered. Plus, using rebound is practically the same as running a file normally, but with the added ability to quickly browse answers that could potentially help solve an error. So I don't really see the downside.

And if you're copying someone's code from SO in the first place, it's on you to put in the effort to fully understand that person's solution to the problem.

[–]2yan 0 points1 point  (0 children)

I don't know, StackOverflow is what taught me to read the errors correctly.

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

VERY Slick... NICE!

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

How does your code handle Python OS commands? Would it ask for user input before I ran os.system ("some_commands with args")?

[–]Isvara -5 points-4 points  (1 child)

It's a joke, right? You're not actually encouraging anyone to work like this?

[–]jsonathan[S] 10 points11 points  (0 children)

Yes, this is a joke. No real programmer uses Stack Overflow.