print - parameters ?
aleaxit at yahoo.com
Tue Oct 5 11:13:08 CEST 2004
Helmut Jarausch <jarausch at igpm.rwth-aachen.de> wrote:
> sorry for this probably very simple question.
> How can I build a parameter list for 'print' ?
You can't really do that, since (alas) it's a statement, not a function.
> I'd like to write a function like
> def myprint(Msg,*Args) :
> print (Msg,)+Args
def myprint(Msg, *Args):
for arg in Args: print arg,
> myprint('this is',x)
> ('this is', <__main__.ABC instance at 0x4084fc8c>)
> instead of
> this is ABC-class
You're printing a tuple, and that uses repr on each item, with commas to
separate and parentheses around it all.
> What am I missing (what sort of thing is the parameter list of print) ?
It's not really a "sort of thing", alas... print is a statement so it
lives by its own rules (a Python wart, Guido's admitted that; maybe it
will change in Python 3000... let's hope!).
More information about the Python-list