print from Python

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Post Reply
malinand
Posts: 31
Joined: Sun Aug 02, 2009 2:10 am

print from Python

Post by malinand »

Is it possible to redirect Python print command output to FreeCAD output window?
It is common practice to use print for exceptions information handling. But print produce only "I/O error"

Andrey
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: print from Python

Post by jriegel »

We could turn on the stdio on the report window, but unfortunnately a lot libs we use have a lot of noice on stdio. So a lot
more would show of when we did that....

Im not digged that deep into python to see if we get a hold on only the python output....
Stop whining - start coding!
wmayer
Founder
Posts: 20324
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: print from Python

Post by wmayer »

Actually it is not a bad idea to print Python errors directly to the output console because it often contains useful information to track down a problem...

Technically this no problem because we already have implemented this feature for our Python console. All what we need to do is to write a new Python extension class with a certain interface and overriding the sys.stderr object. Maybe we could put an option in the preferences which is off by default because the output could be really verbose.
wmayer
Founder
Posts: 20324
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: print from Python

Post by wmayer »

The redirection feature for Python errors is implemented.
Post Reply