print as a function in 2.5 ?

S

Stef Mientki

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,157
Latest member
MercedesE4
Top