print as a function in 2.5 ?

Stef Mientki stef.mientki at gmail.com
Sun Apr 19 19:13:59 CEST 2009


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

Now I guess that one of the reasons to change print from a statement to 
a function,
is the option to override and extend it.
If that's so, choice 2 would be the best choice.
Is that assumption correct ?

Suppose the second choice is the best,
I can now create a function "print",
and have the best of 2 worlds, get my extension and being prepared for 
the future.

def print ( *args ) :
    for arg in args :
        print arg,
    print ('____________ Print Traceback ____________')
    do_extended printer actions

Now doesn't seem to be allowed,
nor is there an import from __future__  :-(

What's the best solution (other than moving to 2.6 or up ?

thanks,
Stef Mientki



More information about the Python-list mailing list