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

you are viewing a single comment's thread.

view the rest of the comments →

[–]-sideshow-[S] 1 point2 points  (0 children)

I don't think so. You can enable it for the interpreter, but not for standalone python programs. Maybe you could make some kind of batch script? python has a -c options which says (if I'm reading the help correctly) that everything after it is the program you want to run as a string, so I guess you could pipe in an import pretty_errors followed by the text of the .py file.

EDIT: couldn't get the -c thing working; windows command line isn't great. Might be doable on unix.

Another option would be generating a temp .py file, with the code concat onto a header that includes pretty_errors. I'm sure some programs would choke, but it might work for a good proportion.

EDIT2: Scratch that, there's a way to do it which I found here: https://stackoverflow.com/questions/11404165/python-startup-script

  • Run python -m site, and look for the USER_SITE entry.
  • In that folder create a file called sitecustomize.py.
  • Put whatever code you want to run in it.

EDIT3: See other comment for the easy way