print as a function in 2.5 ?

Stef Mientki stef.mientki at gmail.com
Sun Apr 19 22:41:55 CEST 2009


Tino Wildenhain wrote:
> Stef Mientki wrote:
>> hello,
>>
>> For several reasons I still use Python version 2.5.
>> I understand that the print-statement will be replaced in Python 
>> version 3.0.
>>
>> At the moment I want to extend the print statement with an optional 
>> traceback.
>> So I've 2 options:
>> 1- make a new function, like "eprint ()", where "e" stands for 
>> extended print
>> 2- make a function "print()" that has the extended features
>
> There is a 3rd option: hook yourself in the output stream and just
> climb the call stack in the write() method. This works (done that
> myself for easy debugging)
>
> The other way if you want to selectively do so, either use
> a form of log (because why must it be print if the output
> is debugging information?) or instead of hooking sys.stdout,
> use another output stream and print >>debug, ... to it.
>
thanks guys,
for the moment I'll stick to another name "v3print" so it can easily be 
replaced.
The third option (by Tino) looks interesting,
but is not suitable in my case,
because the program I'm writing is a kind of IDE (Integrated Development 
Environment),
where the user can create programs, and must have full control over stdout.

cheers,
Stef

> Regards
> Tino




More information about the Python-list mailing list