friendly-traceback / friendly

Friendly-traceback's version used in most situations
https://friendly-traceback.github.io/docs/index.html
MIT License
40 stars 5 forks source link

Use as default Python output #53

Closed MustCodeAl closed 8 months ago

MustCodeAl commented 8 months ago

Is your feature request related to a problem? Please describe. As a beginner of python, the friendly python makes debugging python programs much easier, and it would be even more useful to be default for python programs ran in terminal, and pip package installs.

Describe the solution you'd like Automatically working on python without using friendly command or at the very least allow automatically aliasing the py command with friendly

Describe alternatives you've considered using friendly as alias for py but doesn't work with some python options

Additional context there is a similar tool that does this feature: Better-Exceptions but it is dated

aroberge commented 8 months ago

If I understand correctly, you are suggesting that installing friendly should modify the installed Python version so that friendly should be enabled automatically. The problem with this approach is that if friendly has bugs, there would be no way for a user (especially for a beginner) to figure out if the problem is with Python itself, with their own code, or with friendly. You mention Better-Exceptions: my understanding is that it used to work that way (at least partly) but it now require some explicit method to enable it - either through an environment variable or, when using a REPL, using a special command. This last one is already done with friendly.

You also suggest that friendly should be a replacement for pip.

I'm a single developer working on friendly as a hobby. There are more than 100 core developer working on cPython, and a significant number working on pip. I do appreciate your vote of confidence, but I couldn't possibly keep up with the work being done on cPython and pip to make friendly a suitable alternative. In fact, I have not been able to find the time to work on friendly for the past 8 months. I don't think it is realistic to consider increasing the "power" of friendly so that it could do all you describe.

MustCodeAl commented 8 months ago

If I understand correctly, you are suggesting that installing friendly should modify the installed Python version so that friendly should be enabled automatically. The problem with this approach is that if friendly has bugs, there would be no way for a user (especially for a beginner) to figure out if the problem is with Python itself, with their own code, or with friendly. You mention Better-Exceptions: my understanding is that it used to work that way (at least partly) but it now require some explicit method to enable it - either through an environment variable or, when using a REPL, using a special command. This last one is already done with friendly.

You also suggest that friendly should be a replacement for pip.

I'm a single developer working on friendly as a hobby. There are more than 100 core developer working on cPython, and a significant number working on pip. I do appreciate your vote of confidence, but I couldn't possibly keep up with the work being done on cPython and pip to make friendly a suitable alternative. In fact, I have not been able to find the time to work on friendly for the past 8 months. I don't think it is realistic to consider increasing the "power" of friendly so that it could do all you describe.

not to modify the python version, to make it so when i use python programs on my computer, i can see the friendly colors on the errors. Explicitly doing it through an environment variable could also work. I dont know if im phrasing it correctly, but I just want to be able to see colored output instead of black and white through my python programs without having to modify the python scripts themselves. Similar to how if you compile a program in rust you see the nice colored outputs in the terminal. I dont know if python has the feature built in and ive tried using a couple debug env vars but they didnt work. And I just realized Better Exceptions partially does what I want but only for programs I run with the py command not programs installed pip that can be run without py. I used friendly which has way nice output but I was hoping that it was some how built in or possible to be supported.

aroberge commented 8 months ago

As far as I know, there is no way to do this in general.

MustCodeAl commented 7 months ago

As far as I know, there is no way to do this in general.

Ok so I was able to get it almost working using this

Now my output looks like this:

Screenshot 2024-01-16 at 11 13 53 PM

Is there a way to make it output color, my sitecustomize.py looks like the following:

import friendly
friendly.install()
#friendly.set_stream("capture")
#friendly.set_include("explain")  
#print(friendly.get_output())
# none of options here work for color
aroberge commented 7 months ago

Sorry, I do not have time to do tests right now.

Try

import friendly
friendly.install(formatter="dark")